Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Dears,
I am currently trying to calculate the absolute difference between imports and exports at SKU level in the total. For the same SKU, I have imports and exports in every week. At the end of week 8, I'd like to check the absolute difference between Imports and Exports. How?
Solved! Go to Solution.
@Omega,
Create the following measures and check if you get expected result.
NewMeasure = IF(COUNTROWS(VALUES(Table2[SKU]))=1,Table2[ABSDIFF],SUMX(VALUES(Table2[SKU]),[ABSDIFF]))
Measure 3 = [NewMeasure]/[ExportTotal]
Regards,
Lydia
Hi @Omega
How did you get the redmarked number, that´s the number I´m after but can´t seem to be able to produce.
/Helena
maybe im being daft but why dont you convert the number after you have done the calculation rather than creating absolute figures before you do the sum. ie. * -1
Proud to be a Super User!
Can you please ellaborate further?
SUMX(Table2,ABS(Table2[Export]-Table2[Import])) * -1
(but like i say i could be being daft)
Proud to be a Super User!
Can you share the code for your measure(s) ? PowerBI visuals don't total up columns and rows on measures - it calculates the measure based on the current filter context.
Measure = SUMX(Table2,ABS(Table2[Export]-Table2[Import]))
Your code is doing the absolute value, then summing. You want to sum then do absolute value
Measure = ABS(SUMX(Table2, (Table2[Export]-Table2[Import])))
Thanks!!! My bad didn't realize I'm doing it wrong. Now, I want to take the total absolute value (470) and divide it by the total export per SKU (8510). I tried the following measure:
Measure 2 = SUMX(Table2,[Measure])/SUMX(Table2,Table2[Export]) but I'm not getting correct % 😞
I even tried: Measure 2 = SUMX(Table2,[Measure])/SUM(Table2[Export]) but still wrong because it gets me the total export for all the SKUs 😞
Please advise.
Thanks!
Measure 2 = divide(SUMX(Table2,[Measure]),SUMX(Table2,Table2[Export]))
Proud to be a Super User!
Same values as I had 😞
@Omega,
I can get your expected result by creating the following measures. How do you create visual in your scenario?
ABSDIFF = ABS(SUMX(Table2, (Table2[Export]-Table2[Import])))
ExportTotal = SUM(Table2[Export])
Measure 2 = DIVIDE(Table2[ABSDIFF],Table2[ExportTotal])
Regards,
Lydia Zhang
It's close but when you combine SKUs it won't give the correct value because PBI will calculate the difference at week level then sum up the difference at SKU level. My aim is to calculate the total exports and imports per SKU -> Apply ABSDIFF -> Sum ABSDIFF and the divide by total exports.
@Omega,
What do you mean that "combine SKUs"? Could you please post the screenshot that how you create the visual and how are the incorrect value like?
Regards,
Lydia Zhang
Sorry I was on leave and couldn't reply any time soon. What I meant is to get the difference between exports and imports for each SKU and take the summation for this difference.
In PBI, it doesn't take the difference at SKU level but at the lowest level which is in this case is Weeks. Due to that, the calculations are not correct.
@Omega,
Create the following measures and check if you get expected result.
NewMeasure = IF(COUNTROWS(VALUES(Table2[SKU]))=1,Table2[ABSDIFF],SUMX(VALUES(Table2[SKU]),[ABSDIFF]))
Measure 3 = [NewMeasure]/[ExportTotal]
Regards,
Lydia
Thanks a lot!!! This is the solution I was looking for 😄
divide(SUMX(Table2,[Measure]),calculate(SUMX(Table2,Table2[Export]),sku = 8510))
Proud to be a Super User!
What if I have multiple SKUs?
divide(SUMX(Table2,[Measure]),calculate(SUMX(Table2,Table2[Export]), filter(table2, sku = 8510 && sku = 111))
Proud to be a Super User!
Thanks but again, this will not solve the problem. Assume that I have one million SKUs, I won't be able to type all 1 million SKUs 😞
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
96 | |
90 | |
82 | |
69 |
User | Count |
---|---|
159 | |
125 | |
116 | |
111 | |
95 |