Forum Discussion
evebarratt
Helper I
4 years agoIncorrect Total using Sum, Sumx, and IF Dax
Hi, I have below dataset and table visual.
I got incorrect total from 'Price-GST(Wrong)' measure.
Price-GST(wrong) =
VAR withoutGST = SUM('Table'[Price])
VAR withGST = SUMX(VALUES('Table'[ID]),withoutGST/1.1)
RETURN
IF(SELECTEDVALUE('Table'[GST])=0,withoutGST,withGST)
So I researched and was able to have the correct total from 'Price-GST(Correct)' mesaure.
Price-GST(correct) = SUMX(VALUES('Table'[ID]),[Price-GST(wrong)])
However, i tried to combine those 2 measures into one using VAR but couldn't get what I wanted. Is there any way I can use one measure and still get the correct total?
Hi,
Please try the below measure.
New measure: = SUMX ( ADDCOLUMNS ( VALUES ( Data[ID] ), "@condition", IF ( CALCULATE ( SELECTEDVALUE ( Data[GST] ) ) = 0, CALCULATE ( SUM ( Data[Price] ) ), CALCULATE ( SUM ( Data[Price] ) ) / 1.1 ) ), [@condition] )
2 Replies
- Jihwan_Kim
Super User
Hi,
Please try the below measure.
New measure: = SUMX ( ADDCOLUMNS ( VALUES ( Data[ID] ), "@condition", IF ( CALCULATE ( SELECTEDVALUE ( Data[GST] ) ) = 0, CALCULATE ( SUM ( Data[Price] ) ), CALCULATE ( SUM ( Data[Price] ) ) / 1.1 ) ), [@condition] )- evebarratt
Helper I
It works well! Thanks a lot.