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.
Hello,
I'm having issues with an IF and/or SUMX formula. I essentially need the calculation done at every line level & then aggregated. With my first attempt using IF, the results are correct at the line level but don't sum up properly. It should show $21K, not $35K.
I assume I really need to be using SUMX, but that doesn't seem to be calcing at the line level correctly. Can anyone help pinpoint what I'm doing wrong? Here are my measures:
08.a Expired Release via Scrap = IF([01. Expired PQ] < [07. Gross Scrap] , [01. Expired PQ] , [07. Gross Scrap] ) * -1
08.a2 Expired Release via Scrap = CALCULATE(SUMX(EEORE, IF([01. Expired PQ] < [07. Gross Scrap] , [01. Expired PQ] , [07. Gross Scrap]) * -1 ))
Thanks!
J
Hi @aminw0u,
According to your descriptions above, you may need to firstly summarize your data at [Generic SKU Name] level, then use SUMX to get the correct total in your scenario. The formula below is for your reference.
08.a Expired Release via Scrap = SUMX ( SUMMARIZE ( EEORE, EEORE[Generic SKU Name], "abc", IF ( [01. Expired PQ] < [07. Gross Scrap], [01. Expired PQ], [07. Gross Scrap] ) * -1 ), [abc] )
Regards
I think it makes sense to summarize, but when I do that, it gives me an answer that is even more incorrect than before unfortunately. The 08.3 column is the one that includes the summarize formula.
08.e Expired Release via Scrap =
SUMX (
SUMMARIZE (
EEORE,
EEORE[Generic SKU Name],
"abc", IF ( [01. Expired PQ] < [07. Gross Scrap], [01. Expired PQ], [07. Gross Scrap] )
* -1
),
[abc]
)
Hi @aminw0u
Are the lines in your matrix an exact match to the lines in your source data? Or are these aggregated values?
They are aggregated on some level. I have a data set with 34 columns & I only pulled 7 of those into my filter to drill down through before I got to what you see here.
So for SKU Name 87 you have a values of $71 and $88
Are these values based on multiple rows that have been aggretated to this single line?
Yes, there are several lines which make up that particular row. If it helps, my data is inventory data so it goes down to the SKU, manufacturing site & current branch.
Are the detail lines from the same EEORE table or from a related table? I think we are getting close to the issue.
Everything is pulling from the same table (which is the original data load).
I'm using the latest version that was released Nov 7th.
Possibly but this seems like it should be pretty straight forward. What version of Power BI Desktop are you using?
Here is a cut down model using your exact formula showing it working ok
https://1drv.ms/u/s!AtDlC2rep7a-oB-2n_WxkVzte_RD
So just trying to work out the differences. Are you using calculated measures or calculated columns?
Thanks. I'm using measures. The Expired PQ & Gross Scrap are measures as well. I had tried calculated columns earlier & got circular references, so that didn't seem like the way to go.
Is it possible that this is just a bug? I would have expected my formula to work the same as what you have in your file, and I've had several instances of formulas not working when they should have (including while at a DIAD training with Microsoft instructors looking over my shoulder wondering why it wasn't working).
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 |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |