Interactive sorting based on totals - sql

I have the following report that looks like this in design mode:
The field I'd like to sort on is the <<Expr>> field highlighted in yellow TOTAL row. That expression reads like this:
=ReportItems!Textbox12.Value+ReportItems!Price3.Value
When previewed, the report looks like this:
I'd like to be able to sort the TOTAL row for all of the report. My desired result would have the group with the $38.52 total first, $0.92 total second, and so on. Is this possible?

I would set the Sorting on the Row Group for Patient Name. Sort expressions cannot reference ReportItems so I would get the Expressions inside those Report Items references and copy them into the Sort Expression.
And that is seriously the worst color scheme I have ever seen in 30+ years in IT ... it literally makes my eyes water.

Related

Highlighting differences in child values for parent values in OBIEE or SQL

I can't seem to figure out how to select instances where values in the green circle would be highlighted/selected for every parent/orange-circle value. What would this sort of operation be called?
Trying to translate that into an understandable requirement: You want to select (means filter for) "Load IDs" which have more than 1 "Purchase Order Numbers"?
That's what it reads to me from your data grid because the PO Number is the one that changes the query grain and causes two rows. Everything else is the same.
If that's the case then create a measure which counts the PO Numbers and filter on that.

Percent of Group, not total

It seems like there are a lot of answers out there but I can't seem to relate it to my specific issue. I want to get the breakdown of yes/no for the specific Group. Not get the percent of the yes for the entire population of data.
I have tried the following code in the "What I'm Getting" % of Total cell =
=FormatPercent(Count(Fields!SessionID.Value)/Count((Fields!SessionID.Value), "Tablix1"),)
=FormatPercent(Count(Fields!Value.Value)/Count((Fields!SessionID.Value), "Value"),)
It should just be a case of changing the Scope in your expression to make sure the denominator is the total for the group, not the entire Dataset or Tablix, i.e. something like:
=Count(Fields!SessionID.Value) / Count(Fields!SessionID.Value, "MyGroup")
Where MyGroup is the name of the group, i.e. something like:
If this is still not clear, your best option would be to add a few sample rows, and your desired result for these, to the question so we can replicate your exact issue.
Edit after more info added
Thanks for adding more details. I have created a Dataset based on your example:
And I've created a table based on this:
The group is based on the Group field:
The Group % expression is:
=Fields!YesNoCount.Value / Sum(Fields!YesNoCount.Value, "MyGroup")
This is taking the YesNoCount value of each row and comparing it to the total YesNoCount value in that particular group (i.e. the MyGroup scope).
Note that I'm using Sum here, not Count as in your example expression - that seems to be the appropriate aggregate for your data and the required value.
Results look OK to me:

How do I get MS Access 2007 to calculate row percentages?

How do I write a query in MS Access 2007 that displays both the count AND the percentage of the total records in a table for each row in a specified field?
For instance, if my table has a field called "gender," what is the query I should write to see the row count and percentage of Men and the row count and percentage of Women?
So, if the table had 1000 records, the result would look something like:
Men.....600.....60%
Women...400.....40%
I can easily write a query that just gives me the row count, but I can't figure out how to also see the percentages.
I should mention that I do not know SQL. I use the Design View when creating queries. But if you can give me the text for the query in SQL, I can copy and paste it into a new query and then save it.
It's not part of SQL itself, but you can use a VBA function in a query to count the amount of records in a table: DCount (MSDN).
Copy and paste the following lines in the query designer (top row, one line per column):
TotalMen: DCount("*";"[TableNameHere]";"[Gender]='Male'")
TotalWomen: DCount("*";"[TableNameHere]";"[Gender]='Female'")
You can then get the percentage by performing some simple math on the return values (again one line per column):
TotalPersons: [TotalMen]+[TotalWomen]
PercentageMen: [TotalMen]/[TotalPersons]
PercentageWomen: [TotalWomen]/[TotalPersons]
Don't forget to set the format to Percentage or the values will show up as 0,6 and 0,4 instead of 60% and 40%.
By the way, there are probably more consise ways to do it. I tried to make it readable.
PS: don't forget to replace the names of the tables and fields.

reporting services - sum expression column in tablix

I have a column in my tablix where I manually entered a long nested IF expression (its not in my dataset.) I want to sum the whole column that contains my expression. Is there anyway to do this?
Can I give the tablix column a name, and sum that? Or do I have to take my expressions and add them to my dataset? I rather not do this, because i have 8 datasets, and I would have to add 20 expressions to each one manually.
Assuming your column's expression is like:
=iif(...)
- simply add a similar expression into your summary cell, with sum( ) around it - like so:
=sum(iif(...))

Group keywords by site

I am finding a lot of useful help here today, and I really appreciate it. This should be the last one for the day:
I have a list of the top 10 keywords per site, sorted by visits, by date. The records need to be sorted as follows (excuse the formatting):
2010-05 2010-04
site1.com keyword1 apples wine
keyword1 visits 100 12
keyword2 oranges water
keyword2 visits 99 10
site2.com keyword1 blueberry cornbread
keyword1 visits 90 100
keyword2 squares biscuits
keyword2 visits 80 99
Basically what I need to accomplish involves grouping, but I can't seem to figure it out. Am I heading down the right path, or is there another way to achieve this, or is it just impossible?
Edit:
The dataset is something like this (csv):
site_name,date,keyword,visits
site1.com,2010-04,apples,100
site1.com,2010-04,oranges,99
site1.com,2010-05,wine,12
site1.com,2010-05,water,10
site2.com,2010-04,cornbread,100
site2.com,2010-04,biscuits,99
site2.com,2010-05,blueberry,90
site2.com,2010-05,squares,80
Across the X-axis, we need to have the 'date' value
Across the Y-axis, we need to have the 'site_name' as the primary value, but grouped within that we need to have the 'keyword' followed by the respective 'visits'.
Ok, I think you are going down the right track. It's a little tricky getting the groups right, but this should be able to be solved with grouping.
What it looks like you need is a matrix (the table where you can have dynamic rows and columns) and put the dates in a group across the top. Then group the rows by site name and then (I think) by keyword.
If grouping by keyword doesn't work, try grouping by the row number instead (within the scope of the site name group)? If this doesn't work, try getting your database to produce an extra column with rank in it first. Then you can definitely group by that. What I mean is:
site_name,date,keyword,visits,rank
site1.com,2010-04,apples,100,1
site1.com,2010-04,oranges,99,2
site1.com,2010-05,wine,12,1
site1.com,2010-05,water,10,2
site2.com,2010-04,cornbread,100,1
site2.com,2010-04,biscuits,99,2
site2.com,2010-05,blueberry,90,1
site2.com,2010-05,squares,80,2
You should then be able to add two rows in that group to put the keyword and visits in. If you can't, you might have to resort to fancy rectangle work - in the detail cell, put a rectangle, then two textboxes, with the keyword in the top one and the number of visits in the bottom one.
Create a row grouping on "site" then a child/sub row grouping on "keyword"
You don't need to use a Matrix as you know how many columns you will have, so you can just do it in a table
So the grouping would be something like
=Fields!site_name
with the same value appearing in the text box
then for the next grouping down
=Fields!keyword
ditto for the textbox
you can just use SUM to figure out how many vists =SUM(Fields!vists)
in the group total