SSRS percentage of a total with column groups - reporting-services

I apologize in advance if this is not enough info or if it is confusing (This is my first post to the forum and it's a little hard to explain what i'm trying to do). I have been researching this for a couple days now. This article comes really close to what I need, but this person did not have column groups, just a a single column with an output: SSRS percentage of a total.
Consider this layout and groups:
The idea is to provide the percentage of the total records per PrimaryPayor per Company and then break it out by Year-Month.
This expression:
=CountDistinct(Fields!ID.Value, "Primary_Payor") / CountDistinct(Fields!ID.Value, "Company")
Results in this output (The first image is my output, the second is the desired output):
As you can see, the percentages do NOT group by Year-Month, instead just provides the total percentage of IDs per Payor per Company and repeats it for every Year-Month column. How can I get the percent of Total IDs per payor, company, and month as it shows in the second result image?

After editing my question, I thought of something I hadn't tried.
If I just use =CountDistinct(Fields!ID.Value), this gives the total count for each payor, company, month, plus, I added a Total row.
Then, if I reference those textbox values (instead of trying to calculate the percentage on the fly) divided by the total row, I get my results. I just had to add a column inside of the column group. I should then be able to just Hide my "total" column and display only the percentages.
=ReportItems!Textbox50.Value / ReportItems!Textbox35.Value
Here is the output (with the total counts and then after hiding the "count" column):
Final Results

Try:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "Company")
I removed the Primary_Payor scope leaving the function calculate the count in the cell scope Primary_Payor and DOS_YrMo.
UPDATE:
=CountDistinct(Fields!ID.Value) / CountDistinct(Fields!ID.Value, "DOS_YrMo")
Let me know if this helps.

Related

How to sum a row based on the total group in SSRS

Im facing an issue whereby how to sum the % for each of column based on group in SSRS by using expression. Refer my use case below
I have one outcome which all the product with a percentage result. Refer to my screenshot
enter image description here
Below are my SSRS template.
enter image description here
How we get percentage result. Example: Product PG is based on 13(based on total PG) divide 51(total Inv)
Issue: I want to sum each of percentage result for all the item Example 25% + 41% + 4% and etc to populate under excel column V6.
Therefore i need some ideal how to write in SSRS expression or it only can done via query.
Seek for any ideal how can this be done.
You can try as below since you have use static columns:
=(Sum(TotalTintCash)/Sum(TotalInv)+Sum(TotalTintFOC)/Sum(TotalInv))
And then, you can provide number formatting to percentage

Calculate difference between multiple group columns in SSRS Report

First post in stackoverflow - so forgive me if I don't get this right. I have an SSRS report with a matrix which groups Quantity, Total Spend and Average Cost by part number for each year. Part Number and description down the left and the the years along the top. I want to add a delta column in each year after the first year which shows the change in price from the previous year. I have seen examples of how to get the difference between first and last year - but not the difference between each year and the previous one. I have hidden the delta column for the first year - no would love some guidance on how to calculate the difference in cost.
So from the image below the first row in the delta column under FY2019 would show -€0.01 as price has reduced from 0.59 to 0.58.
You haven't explained how if Avg. Cost is calculated in your report but I'm assumming it's just something like =SUM(Fields!Spend.Value) / SUM(Fields!Qty.Value)
You've not shown your report design so I can't tell what your row/column groups are called but I'll assume you have rowgroup by Part and one by Year. Let's assume your column group name is PeriodID so it's the same as my demo report.
In this case you can use the PREVIOUS() function to get the previous values to compare against.
I set up a similar report to demonstrate. As you can see in my case the year column is grouped using a columngroup called PeriodID
The expressions highlighted are as follows.
Price. This is just Cost/Qty =SUM(Fields!Cost.Value)/SUM(Fields!Qty.Value)
lastprice. This is just for illustration and debugging. It uses the PREVIOUS() fucntion to get the previous year's data
=Previous(Sum(Fields!Cost.Value), "PeriodID") / Previous(Sum(Fields!Qty.Value), "PeriodID")
Note that "PeriodID" is the name of the column group (case sensitive). This is scope for the previous function so it know to get data from the previous column group.
delta. This is the final output. It's just the current "Price" expression minus the "lastprice" expression.
=(Sum(Fields!Cost.Value) / Sum(Fields!Qty.Value)) - (Previous(Sum(Fields!Cost.Value), "PeriodID") / Previous(Sum(Fields!Qty.Value), "PeriodID"))
The final output looks like this (I've not hidden the column for the first column group or hidden last price, just so you can see it working). Also, if you see slight differences in the delta column compared to what you might expect, it's just down to the fact that the numbers are formatted to 2 decimals but my test data is up to 14 decimals.

SUM expression with column and row scope

I work in lending and we are trying to get the percentages of purchases and refis to show for the months. The problem that I am having is that I cannot get the scope correct.
Here is the current list
Andhere are the row groups
I know this is definitely a scope issue - I just can't figure out a way to have it take into account the month and the year. I have had success with it doing the percent of the year value. I am trying to simply show the percent of purchases and Refis for a given month for a given year.
For example, If we have 60 purchases and 40 Refinances for January of 2019 - I want it to show 60% and 40%.
I have tried messing around with the row and columns groups every which way and I still cannot seem to figure it out. Any help would be largely appreciated.
= SUM(Fields!TOTALLOANAMT.Value, "Grouped_Loan_Purpose5") /
SUM(Fields!TOTALLOANAMT.Value, "App_Sent_Year1")
I have a fairly simple solution that you could use to avoid any headache involved with grouping. I would suggest simply using the values in the textboxes to calculate your percentages. You can just do something like the following.
=(ReportItems!PurchasesTextbox.Value / ReportItems!TotalTextbox.Value) * 100
=(ReportItems!RefinanceTextbox.Value / ReportItems!TotalTextbox.Value) * 100
Then you can just format as percentages and leave everything else alone.

Calculate the average in SSRS 2016

I am using SSRS 2016 application to pull data from SharePoint list.
My task is to calculate the average DaysUsed and the average Percentage from a column.
It is a Matrix report which has two columns:
Sum(Fields!Days.Value)
Sum(Fields!Percentage.Value)
The task is to show the average days and average percentage.
I have tried the =Avg(Fields!Days.Value) but this shows wrong result.
UPDATE
Yes, the matrix is grouped by the Month to show each relevant month.
See the screenshot below what I have tested so far.
The DaysUsed is a calculated between 2 fields [FromDate] and [UntilDate] by summarising the total days minus the weekends. see below:
=(DateDiff(DateInterval.day,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")), CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))+1)
- (DateDiff(DateInterval.WeekOfYear,CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")), CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")))*2)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!FromDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 1,1,0)
- IIF(Weekday( CDate(format(Fields!UntilDate.Value,"MM-dd-yyyy")),1) = 7,1,0)
Furthermore, the [DaysUsed] row then consists of IIF(value is null then show 0 otherwise show the total value of days used).
=IIF(IsNothing(Sum(Fields!Days.Value)), "0", Sum(Fields!Days.Value) )
Sum(Fields!Days.Value)/CountRows()
Shall give you average days. Similarly goes for others as well.
If you has a field called Fields!Days.Value, I guess your data in the screenshot is already grouped by month. This means the expression
=Avg(Fields!Days.Value)
gives you the average over all Days (sum of all days / count of all days).
If you want to use the grouped values (by mounth) you either can use the following expression when you are inside the scope (the monthly socpe; indicated by the brackets on the most left side on your tablix)
=Sum(Fields!Days.Value) / Count(Fields!Days.Value)
If you are not in the scope you have to tell the tablix that is should use your monthly grouping. For this you can use the following:
=Sum(Fields!Days.Value, "YourMonthGroupName") / Count(Fields!Days.Value, "YourMonthGroupName")

How can I add an aggregate percentage to an SSRS report based on two specific columns in a matrix?

I am somewhat new to SSRS and I have built a matrix report that looks fairly simple:
Supplier [AccDate]
[SupplierName] Sum(PurchasingCredit)
Total <<Expr>>
The actual report shows month-by-month sales data for a year in addition to Current YTD and Previous YTD columns (joined via UNION clause in base query) in addition to a column showing Year-over-Year % as difference between the Current YTD and Previous YTD columns (also joined via union).
I was able to apply a dynamic format to the Year-over-Year column using the following expression in the Format property to show the YOY column as a percentage and the others as dollar amounts:
=IIF(Fields!AccDate.Value <> "YOY", "'$' #,0.00;'$' -#,0.00", "#,0.00 %;-#,0.00 %")
The last thing I need to do is to show the column totals, which are working for each column with the exception of the year-over-year percentages using the following:
=IIF(Fields!AccDate.Value <> "YOY", SUM(Fields!PurchasingCredit.Value), 0)
In the year-over-year (YOY) column, a sum of percentages doesn't make sense: I need it to recalculate this value based on the sums of the "CYTD" and "PYTD" columns, but I can't seem to figure it out. Any help would be greatly appreciated. I am guessing it is probably an application of scope, but the MS articles that attempt to explain this are very confusing.