Forum Discussion
SUM/SUMIF Function In DAX
Please assist. Am i using the correct function in dax for SUM/SUMIF equilvalents in Dax, Also when do i use Calculate?
My Totals are inflated, my conversions from Excel to DAX, might not be correct.
Measure: Depreciation and amortisation in Excel(see Excel link for Formula), DAX:
WorkingCapitalMvtsInclProvisions =
[Other asset movements]
+ [Working capital - budget flex]
+ CALCULATE(
SUM('ZTBR'[Amount in USD]),
'ZTBR'[Roll_Up_Function] = "Provision movements"
)<p>Formula in Excel: <li-code lang="markup">=-SUMIF(Details!B:B;'Cash Flow'!G39;Details!G:G)
AND Disposals & impairment of fixed assets.
DAX:
Disposals & impairment of fixed assets =
CALCULATE(
SUM('ZTBR'[Amount in USD]),
'ZTBR'[Roll_Up_Function] IN {
"Profit on disposal of pooling equipment",
"Scrapped pooling equipment",
"Impairment or valuation adjustment of pooling equipment",
"Disposals or valuation adjustments of other fixed assets"
}
)
Excel Formula:
=SUM(K21:K24)
PBIX: https://drive.google.com/file/d/1-wHE0e50nSM9-wSq4dTxStDX58APO_MI/view?usp=sharing
Excel: https://docs.google.com/spreadsheets/d/1ubo9TAz2zzCpKbfO5SFBMjFLgjFtUxhY/edit?usp=sharing&ouid=104129043494164133703&rtpof=true&sd=true
3 Replies
- Greg_DecklerCommunity Champion
Yrstruly2021 Several different issues here. Generally use would use something like SUMX(FILTER(...), ...) for SUMIF. See Excel to DAX Translation here: S Excel to DAX Translation - Microsoft Fabric Community
For totals, 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- Yrstruly2021Helper V
So most of my calculations are wrong so far, leaving me with inflated figures. Cash Flow Imbalance should be 0. Can you check thepbix file if you get 0 after correct calculations has been applied?
- Yrstruly2021Helper V
Both of the solutions you provided for SUMIF gives the same data/value output.
WorkingCapitalMvtsInclProvisions = [Other asset movements] + [Working capital - budget flex] + CALCULATE( SUM('ZTBR'[Amount in USD]), FILTER( ALL('ZTBR'), 'ZTBR'[Roll_Up_Function] = "Provision movements" ) ) AND WorkingCapitalMvtsInclProvisions = [Other asset movements] + [Working capital - budget flex] + SUMX( FILTER( 'ZTBR', 'ZTBR'[Roll_Up_Function] = "Provision movements" ), 'ZTBR'[Amount in USD] ) AND WorkingCapitalMvtsInclProvisions = [Other asset movements] + [Working capital - budget flex] + CALCULATE( SUM('ZTBR'[Amount in USD]), 'ZTBR'[Roll_Up_Function] = "Provision movements" )