Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I just got stuck on an issue, that I guess should be easy, but I just cant seem to solve it. I have searched the forum and tried several of the threads out there, but…just no luck ☹
So, I have a mastertable with information, including volume per Month.
What I want to achieve:
I want to be able to compare Volumes compared to different months. For instance; Compare September volumes vs October volumes. Also, between years if possible. See picture below, I want to be able to see (A) compared to the specific months I choose.
Some factfulness:
HI @tonijj,
You can refer to below steps to create a matrix visual to achieve your requirement:
Steps:
1. Create a matrix visual with 'Service'[Service] as row, 'Volume'[Datakey].[Month] as column, 'Volume'[Volume] as value.
2. Write a measure to calculate 'MOM diff' and drag to value fields.
MOM Diff = VAR currDate = MAX ( Volume[DateKey] ) VAR currTotal = CALCULATE ( SUM ( Volume[Volume] ), FILTER ( ALLSELECTED ( Volume ), FORMAT ( [DateKey], "mm/yyyy" ) = FORMAT ( currDate, "mm/yyyy" ) ), VALUES ( Volume[SID] ) ) VAR prevTotal = CALCULATE ( SUM ( Volume[Volume] ), FILTER ( ALLSELECTED ( Volume ), FORMAT ( [DateKey], "mm/yyyy" ) = FORMAT ( DATE ( YEAR ( currDate ), MONTH ( currDate ) - 1, 1 ), "mm/yyyy" ) ), VALUES ( Volume[SID] ) ) RETURN IF ( prevTotal <> BLANK (), currTotal - prevTotal )
Result:
Regards,
Xiaoxin Sheng
Hi @v-shex-msft
Im almost there I think, however, I think I need that last nudge.
It doesnt show any numbers unfortunately, even though it is a volume difference. See screenshot.
I have uploaded the pbix file for reference, I guess its easier to understand instead of using a simple example as I used in my first post.
Link: File on Onedrive
HI @tonijj,
I can't download sample file from your link, can you fix it?
Regards,
Xiaoxin Sheng
Hi @tonijj,
After play with your sample file, I found you modify my formula and use 'current date' to compare with 'current date'.
I modify the formula to let it works, please try to use following measure formulas if it suitable for your requirement:
MOM Diff = VAR currDate = MAX ( DateTable[DateKey] ) VAR currTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) ), VALUES ( Services[SIN] ) ) VAR prevTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) - 1 ), VALUES ( Services[SIN] ) ) RETURN IF ( prevtotal <> BLANK (), currTotal - prevTotal )
Regards,
Xiaoxin Sheng
That is just perfect, works like a charm!
Thanks so much for the help!
Now, if possible, please forward the feedback internally that something like this should be available as a quick measure in future releases 🙂
HI @tonijj,
I don't think quick measure can generate similar dax formula.
>>Is there a way to modify it so it would work on both levels, both "Host Name" and "SIN" ?
You can try to add values function to apply filter effect on that formula:
MOM Diff = VAR currDate = MAX ( DateTable[DateKey] ) VAR currTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) ), VALUES ( Services[SIN] ) ) VAR prevTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) - 1 ), VALUES ( Services[SIN] ), VALUES ( Service[Host Name] ) ) RETURN IF ( prevtotal <> BLANK (), currTotal - prevTotal )
Regards,
Xiaoxin Sheng
Thanks for the response!
I tried adding the "Hostname" as well, the remaining issue is that the Totals are not correct. I have found the issue; The formula for "Diff MOM" does not add a variance per hostname level when drilling down, which means that the Total is incorrect. See attached pictures.
At first I thought it had to do with "Allselected" and changed it to use the "All" formula, but that didnt do it.
Any ideas for this last step?
Thanks again, I really do appreciate the help!
Hi @tonijj,
It seems like I only add 'host name' filter on previous total variable,now I add it to current total variable, maybe you can try ot use following formula if it fix the issue.
MOM Diff = VAR currDate = MAX ( DateTable[DateKey] ) VAR currTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) ), VALUES ( Services[SIN] ), VALUES ( Service[Host Name] ) ) VAR prevTotal = CALCULATE ( SUM ( DetailedVolumes[Volume] ), FILTER ( ALLSELECTED ( DetailedVolumes ), MONTH ( [DateKey] ) = MONTH ( currDate ) - 1 ), VALUES ( Services[SIN] ), VALUES ( Service[Host Name] ) ) RETURN IF ( prevtotal <> BLANK (), currTotal - prevTotal )
BTW, 'all' function will ignore other filter effects, so I use 'allselected' function to instead.(it can also break current row contents filter but not ignore other filters)
Regards,
Xiaoxin Sheng
Hi,
I actually did try to add that line to the formula, but it didnt work. Well, except for that the "hostname" is in the table "Detailedvolume". In any case, I get the same result, it leaves the "MOM Diff" blank even though there is a difference, but only on hostname level.
If the formula would calculate on that level as well Im pretty sure the Totals would be fine. Any other suggestions?
Ps. Of course youre right about the "ALL" function, thanks for the explanation, think I was just too tired when I tried that out last week 🙂 Appreciate the explanation!
Hi @tonijj,
Yes, measure with specific filters has some trouble to calculate on total level, maybe you can take a look at following blog which told about hierarchy level handling.
Clever Hierarchy Handling in DAX
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |