Showing posts with label entire. Show all posts
Showing posts with label entire. Show all posts

Tuesday, March 27, 2012

Filter and Sort Priority

I have a report with a category that filters for "top N" categories, but it is preventing the entire data set from being evaluated so that the series subtotals are incorrect. Is there a way to change the precedence, so that the subtotals are computed across the entire data set, and the "top N" is evaluated afterwards?

I attempted to solve this problem, or work around it, by having all relevant computation performed in the data source (which required dynamic sql with nested selects and window functions). Even with the data perfectly arranged and sorted in advance, the "TopN" feature of reporting services STILL managed to screw up the results. I've concluded that "TopN" is broken.

However, I found a useable work around. I added still another 'select' layer on my datasource with a dense_rank() function, and then used its result in the filter expressions of the relevant 'category.' Problem solved.

|||

I ran into the same problem and I found that this could be resolved though Reporting Services by adding the following to the group's visibility expression:

=IIF(RUNNINGVALUE(Fields!User.Value,COUNTDISTINCT,"table1_Domain")<11,False,True)

This report is counting top users of a web site that stores hits in a database table which is group by domain, then user.

In the report, I created a field: COUNT(Fields!User.Value). The inner group is then is sorted by this field (descending).

So, the logic in this expression is: Every time the user name changes it keeps that in the running total. The running total is reset when the group above it (the user's domain) changes. IIF the running total is less than 11, then Hidden = False.

So, while all values may still be processed, it only shows the top 10.

Hope this helps others

BTW, there is one drawback - since I'm using an expression for the visibility, I can't make this a drill-down field (since drill-down is also a function of visibility). If I select the "Visibility can be toggled by another report item", the report still displays as expected when first rendered, but if it's collapsed then expanded, ALL values for the group will appear, not just the top 10. I guess the visibility expression is only process at initial report rendering time, and not each time the group is collapsed/expanded.

|||

Okay, I'm a but dense today - there is another way to do this. The above will guarantee that ONLY 10 values are returned, but if you remove the sort, and use only the filter for TopN, you'll get the top 10 VALUES (some may duplicate). So, the above solution may return

DOMAIN Logon Count

~~~~~~~~~~~~~~~~~~~~~~~~

Domain1

UserA 10

UserB 10

UserC 9

........etc...upto

UserJ 2

Domain2

etc

However, using only TopN (no sort), may return

Domain1

UserA 10

....

UserJ 2

UserK 2

UserL 2

Domain2

etc

So, TopN by itself (without Sort) can return more than 10 values because there are multiples of the last entry with the same value. My solution in the previous posting depends on Sort, and simply hides everything after the 10th entry.

If someone else finds a way to list just the first 10 entries in a sorted list, please post. I don't like my solution too much because I can't further drill-down into the entries.

sql

Filter and Sort Priority

I have a report with a category that filters for "top N" categories, but it is preventing the entire data set from being evaluated so that the series subtotals are incorrect. Is there a way to change the precedence, so that the subtotals are computed across the entire data set, and the "top N" is evaluated afterwards?

I attempted to solve this problem, or work around it, by having all relevant computation performed in the data source (which required dynamic sql with nested selects and window functions). Even with the data perfectly arranged and sorted in advance, the "TopN" feature of reporting services STILL managed to screw up the results. I've concluded that "TopN" is broken.

However, I found a useable work around. I added still another 'select' layer on my datasource with a dense_rank() function, and then used its result in the filter expressions of the relevant 'category.' Problem solved.

|||

I ran into the same problem and I found that this could be resolved though Reporting Services by adding the following to the group's visibility expression:

=IIF(RUNNINGVALUE(Fields!User.Value,COUNTDISTINCT,"table1_Domain")<11,False,True)

This report is counting top users of a web site that stores hits in a database table which is group by domain, then user.

In the report, I created a field: COUNT(Fields!User.Value). The inner group is then is sorted by this field (descending).

So, the logic in this expression is: Every time the user name changes it keeps that in the running total. The running total is reset when the group above it (the user's domain) changes. IIF the running total is less than 11, then Hidden = False.

So, while all values may still be processed, it only shows the top 10.

Hope this helps others

BTW, there is one drawback - since I'm using an expression for the visibility, I can't make this a drill-down field (since drill-down is also a function of visibility). If I select the "Visibility can be toggled by another report item", the report still displays as expected when first rendered, but if it's collapsed then expanded, ALL values for the group will appear, not just the top 10. I guess the visibility expression is only process at initial report rendering time, and not each time the group is collapsed/expanded.

|||

Okay, I'm a but dense today - there is another way to do this. The above will guarantee that ONLY 10 values are returned, but if you remove the sort, and use only the filter for TopN, you'll get the top 10 VALUES (some may duplicate). So, the above solution may return

DOMAIN Logon Count

~~~~~~~~~~~~~~~~~~~~~~~~

Domain1

UserA 10

UserB 10

UserC 9

........etc...upto

UserJ 2

Domain2

etc

However, using only TopN (no sort), may return

Domain1

UserA 10

....

UserJ 2

UserK 2

UserL 2

Domain2

etc

So, TopN by itself (without Sort) can return more than 10 values because there are multiples of the last entry with the same value. My solution in the previous posting depends on Sort, and simply hides everything after the 10th entry.

If someone else finds a way to list just the first 10 entries in a sorted list, please post. I don't like my solution too much because I can't further drill-down into the entries.

Monday, March 26, 2012

fill up spaces with dots in a column

Hi,

I currently have a column in a table with data type char and length 500. However, not every column fills up the entire 500 length, and I would like to fill up the rest of the spaces with dots. Is there a setting in SQL to do this? I do not want to use varchar since I want a fixed length with dots at the end. Any ideas?

Thanks,
Alan

I can't really imagine why you would have that requirement, it is kinda backwards.

If your goal is to display the data padded with dots up to a total length of 500, then I'd suggest that you do use a varchar for storage of your data (without dots).
When you want to retrieve it, then you pad it. Something like this;

create table #x (mystring varchar(50) not null)
insert #x
select 'abc' union all
select 'defgh'

select mystring + replicate('.', 50 - len(mystring))
from #x

drop table #x
go


abc...............................................
defgh.............................................

Would that work as an idea for you?

/Kenneth

Friday, March 9, 2012

File Watcher Task doesnt wait for the entire file to be completely finish before it completes

Hey there

Ive built an SSIS package which generates a file from a legacy system and then downloads the file into a designated folder on the server. I need the file watcher task to wait for a the file to completely finish loading before it says it is complete. Currently, as soon as the file is created, the WMI step finishes.

Any help would be greatly appreciated!

Kind Regards

David

Check out http://www.sqlis.com/default.aspx?23

Thanks,
Loonysan

|||

Hi

Thanks for that. We decided to take a different approach though.

Ive downloaded another file watcher task from Konesans. Konesans.Dts.FilewatcherTask.FileWatcherTask. I have added it into my SSIS package and it is working like a dream!

However, when to Add it to the SQL Server Agent, I get a strange error message (Package Execution Progress):

- -> Wait for File to Download

Validation has started

Error: The task has failed to load. The contact information for this task is "".

Error: There were errors during the task validation

Validation is completed

Any ideas of how to resolve this?

Thanking you in advance

David

|||

Konesans file watcher is the same one as http://www.sqlis.com/default.aspx?23

Please check if this component is installed in the machine where you are trying to execute the package via SQL Agent. It looks like the SSIS Package is not able to load the FileWatcher Task at runtime.

If the problem persists - contact http://www.konesans.com/contact.aspx

Thanks,
Loonysan

File Watcher Task doesnt wait for the entire file to be completely finish before it complete

Hey there

Ive built an SSIS package which generates a file from a legacy system and then downloads the file into a designated folder on the server. I need the file watcher task to wait for a the file to completely finish loading before it says it is complete. Currently, as soon as the file is created, the WMI step finishes.

Any help would be greatly appreciated!

Kind Regards

David

Check out http://www.sqlis.com/default.aspx?23

Thanks,
Loonysan

|||

Hi

Thanks for that. We decided to take a different approach though.

Ive downloaded another file watcher task from Konesans. Konesans.Dts.FilewatcherTask.FileWatcherTask. I have added it into my SSIS package and it is working like a dream!

However, when to Add it to the SQL Server Agent, I get a strange error message (Package Execution Progress):

- -> Wait for File to Download

Validation has started

Error: The task has failed to load. The contact information for this task is "".

Error: There were errors during the task validation

Validation is completed

Any ideas of how to resolve this?

Thanking you in advance

David

|||

Konesans file watcher is the same one as http://www.sqlis.com/default.aspx?23

Please check if this component is installed in the machine where you are trying to execute the package via SQL Agent. It looks like the SSIS Package is not able to load the FileWatcher Task at runtime.

If the problem persists - contact http://www.konesans.com/contact.aspx

Thanks,
Loonysan

Sunday, February 26, 2012

file size of restore

I don't know why it wants 500GB but you do need the entire size of the data
and log files not just the data itself. It is a good idea to have extra
space but you may be pushing it a little too far if you only have 3GB.
Andrew J. Kelly SQL MVP
"Jack Vamvas" <DEL_TO_REPLY@.del.com> wrote in message
news:VvGdna6Hf7i_DF3bnZ2dnUVZ8rOdnZ2d@.bt.com...
> Hi
> I did an initial file size of a db to 100GB .
> The backups reflect the true size of the DB (about 3GB). However if you
> try and restore the DB it wants 500GB of disk space. Is there anyway to
> restore so it only restores the size of the data?
>
>
>
>
>
>I don't know why it wants 500GB
Perhaps the initial size was 100GB and it has now grown to 500GB? Doesn't change what you are
saying, though... :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OMhxzCd3HHA.2312@.TK2MSFTNGP06.phx.gbl...
>I don't know why it wants 500GB but you do need the entire size of the data and log files not just
>the data itself. It is a good idea to have extra space but you may be pushing it a little too far
>if you only have 3GB.
> --
> Andrew J. Kelly SQL MVP
> "Jack Vamvas" <DEL_TO_REPLY@.del.com> wrote in message
> news:VvGdna6Hf7i_DF3bnZ2dnUVZ8rOdnZ2d@.bt.com...
>