Forum Discussion
DAX wrong total
Hi,
I have the measure (Testing Step 2 Cash Improvement ) that gives a wrong total, the total should be 684,507, but it is giving 691,141.
This the dax:
- Anonymous2 years ago
Hi sabd80,
Here are some steps you can follow to troubleshoot the issue:
Here are my test data:
1.Create a measure
Testing Step 2 Cash Improvement = ROUNDUP ( SUMX ( SUMMARIZE ( 'Supplier Spend Analysis', 'Supplier Spend Analysis (2)'[3.Step 2 DPO Days Move Each Supplier] ), 3000000 * 'Supplier Spend Analysis (2)'[3.Step 2 DPO Days Move Each Supplier] ), 0 )2.Final output
In order for you to solve the problem faster, you can refer to the following documentation
How to Get Your Question Answered Quickly - Microsoft Fabric Community
Best Regards,
Albert He
10 Replies
- bhanu_gautamSuper User
Greg_Deckler , your favourite topic 😃
- Greg_DecklerCommunity Champion
sabd80 First, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8 - ryan_mayuSuper User
maybe you can try
sumx('Supplier Spend Analysis',3000000 * [3.Step 2 DPO Days Move Each Supplier] )if it's still not correct, pls provide the sample data and expected output - ALLUREANSolution SageTry this one:Testing Step 2 Cash Improvement = SUMX('Supplier Spend Analysis', 3000000 * [3.Step 2 DPO Days Move Each Supplier])
- sabd80Helper IV
that did not work, the supplier code should be the same.
- saudansariHelper II
This should work -
TCI = SUMX('Table (2)', 3000000 * 'Table (2)'[DPO])
- AnonymousNot applicable
Hi sabd80,
Here are some steps you can follow to troubleshoot the issue:
Here are my test data:
1.Create a measure
Testing Step 2 Cash Improvement = ROUNDUP ( SUMX ( SUMMARIZE ( 'Supplier Spend Analysis', 'Supplier Spend Analysis (2)'[3.Step 2 DPO Days Move Each Supplier] ), 3000000 * 'Supplier Spend Analysis (2)'[3.Step 2 DPO Days Move Each Supplier] ), 0 )2.Final output
In order for you to solve the problem faster, you can refer to the following documentation
How to Get Your Question Answered Quickly - Microsoft Fabric Community
Best Regards,
Albert He
- sabd80Helper IV
Hi All,
apologies for the late reply I was on leave.
None of the above are working.
The measure that gives the worng total relies on othe measures as in below screenshot:
and below are the measures:
Total Spend (last 12 mth) =
CALCULATE( [Total Spend $],
FILTER (
ALL ( 'Calendar - Invoice Date'),
DATEDIFF (
'Calendar - Invoice Date'[Calendar Date],
TODAY (),
MONTH
) >= 1
&& DATEDIFF (
'Calendar - Invoice Date'[Calendar Date],
TODAY (),
MONTH
) <= 12
)
)
------------------------Total Spend $ Yearly All Suppliers last 12 mths =
CALCULATE([Total Spend (last 12 mth)],ALLSELECTED(), ALL(Supplier))the value= 773,041,452.71
-----------------------1.Weighted Avg per Supplier last 12 mths =
DIVIDE([Total Spend (last 12 mth)], [Total Spend $ Yearly All Suppliers last 12 mths])
------------------------------------------2.Step 2 Avg Days Payment Difference =
CALCULATE(
AVERAGE('Supplier Spend Analysis'[Step 2 Days Payment Difference]) ,
FILTER (
ALL ( 'Calendar - Invoice Date'[Calendar Date] ),
DATEDIFF (
'Calendar - Invoice Date'[Calendar Date],
TODAY (),
MONTH
) >= 1
&& DATEDIFF (
'Calendar - Invoice Date'[Calendar Date],
TODAY (),
MONTH
) <= 12
)
)
--------------------------------------3.Step 2 DPO Days Move Each Supplier =
[1.Weighted Avg per Supplier last 12 mths] * [2.Step 2 Avg Days Payment Difference]
----------------------------------4.Step 2 Cash Improvement =
3000000 * [3.Step 2 DPO Days Move Each Supplier]
-----------------------------------Testing Step 2 Cash Improvement =
VAR NewTable=
SUMMARIZE('Supplier Spend Analysis', Supplier[Supplier Code Caption],"total",[4.Step 2 Cash Improvement])
RETURN
IF(HASONEVALUE(Supplier[Supplier Code Caption]),
[4.Step 2 Cash Improvement] ,SUMX(NewTable, [total])
)- sabd80Helper IV
also the data has been refreshed and it has different figures.