Forum Discussion
SUMX Different Column Depending On IF Condition
- 3 years ago
Palmtop
Sorry fo the late response. The problem is coming from the ALLSELECTED in the Duplicate measure. This has to be done manually.Total Sales = VAR SelectedTable = ALLSELECTED ( SalesProfiles ) RETURN SUMX ( SUMMARIZE ( SalesProfiles, ProjetList[ID_Project], ProjetList[ID_Task] ), IF ( CALCULATE ( COUNT ( SalesProfiles[ID_Project] ), SelectedTable, VALUES ( SalesProfiles[ID_Project] ) ) = 1, SUM ( SalesProfiles[TotalSalesSingle] ), SUM ( SalesProfiles[TotalSalesMulti] ) ) )
Hi tamerj1 ,
Thanks for the quick reply, I gave it a try but it gave me this -
The TotalSales takes the correct values from column "TotalSalesSingle" (856 and 698) but the Total returns 996 instead of 1554. Any thoughts as to why?
Thanks!
please try
Total Sales =
VAR SelectedTasks =
ALLSELECTED ( ProjetList[ID_Task] )
VAR AllProjectList =
ALL ( ProjetList )
RETURN
SUMX (
VALUES ( ProjetList[ID_Project] ),
IF (
COUNTROWS (
FILTER (
AllProjectList,
ProjetList[ID_Project] = ProjetList[ID_Project]
&& ProjetList[ID_Task] IN SelectedTasks
)
) = 1,
CALCULATE ( SUM ( SalesProfiles[TotalSalesSingle] ) ),
CALCULATE ( SUM ( SalesProfiles[TotalSalesMulti] ) )
)
)
- Palmtop3 years ago
Helper I
Hi tamerj1 ,
Thanks for the reply. I've tried it but again, it will return TotalSalesMulti if I select all 3 ID_Tasks.
In this configuration I'd like it to return 351, 856, 231 in my TotalSales column instead of 351, 765, 231. BUT still return i.e. 562 if I only select ID_Task = 1055. That's the part I'm struggling.
Hope that makes sense.
- Palmtop3 years ago
Helper I
Hi tamerj1 ,
Of course, please let me know if the link doesn't work.
https://1drv.ms/f/s!AndVpJp2VQectSrHRNEZnOIC2Kqj?e=CA0QS6
Thanks!