SUM expression with column and row scope - reporting-services

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.

Related

Column cannot return the measure values - DAX divide function and filters

I would love to do some slicer filtering (icon based) - which I already did and it works for me well when I have the values in columns. I have the issue when I wanted to use measures instead of columns.
I am not allowed to connect measures in data model with table "Icons YTD", therefore I decided to create column (column could be connected in data model with my icon table). I tried everything but the results are every time wrong.
Picture available here:
Measure works:
Actual/Planned Hours [%] - MEASURE = DIVIDE([YTD Actual Hours],[YTD Planned Hours])
Column doesn't works: (shows everywhere 0) even the same calculation is used
Actual/Planned Hours [%] - COLUMN = DIVIDE([YTD Actual Hours],[YTD Planned Hours])
or I tried
Actual/Planned Hours [%] - COLUMN = Hours[Actual/Planned Hours [%] - MEASURE]
and I tried lot of more, but nothing helped me.
Calculated and used measures for calculations above:
YTD Actual Hours = CALCULATE(SUM(Hours[Actual Hours]), Months[YTD Months]=true,ALLEXCEPT(Hours, Hours[ID], Hours[P],Hours[D], Hours[Actual Hours]))
YTD Planned Hours = CALCULATE(SUM(Hours[Planned Hours]), Months[YTD Months]=true,ALLEXCEPT(Hours, Hours[ID], Hours[P],Hours[D], Hours[Planned Hours]))
Do you have any idea how to create it?
Thank you a lot!
The problem has nothing to do with icons and everything to do with the fact that you cannot filter by measures without jumping through some hoops. Here is a very good video on filtering with measures.

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")

SSRS percentage of a total with column groups

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.

How to calculate % in table

I am trying to find-out % in the column level which should 4121/7975-52% similar to other also but somehow it is not working & showing 13%. Kindly help me out.
You will need to use a scope in the expression you are using to calculate the percentage. Month, in the example below, is the scope.
=Fields!qty.Value/Sum(Fields!qty.Value, "Month")
Since I don't have your RDL, you will need to determine what the scope name should be based on the group name for the months (Jan, Feb. etc.). This can get a little tricky, so you may have to try a few different scopes to get what you need. Chances are it will be whatever the name of the field is you are using for the month values. The group properties for that column will show the name, too.

TIMESTAMPDIFF giving unexpected result

Why is
TIMESTAMPDIFF(MONTH, '2015-12-25', '2016-02-24')
giving me 1? I would expect 2016-01-25 to be 1.
My guess is that it is actually returning something like 1.999 months and it is being simply rounded down.
How can I work around this? Or is there another function to use.
I tried PERIOD_DIFF but it does not take into account days
PERIOD_DIFF(DATE_FORMAT('2016-02-24','%Y%m'),DATE_FORMAT('2015-12-25','%Y%m'))
According to the documentation, the unit for the result is an integer, in your case it will return the whole number of months between the two dates, which is one (as the second month is not yet completed).