Forum Discussion
Starts with question
I have a measure Total Sales = sum(SALES[Sales])
If the customer name starts with "Acme" reduce SALES[Sales] by 12%, if the customer name starts with "Vect", reduce SALES[Sales] by 10%, if customer name starts with "Merc", reduce SALES[Sales] by 9%, else sum(SALES[Sales]).
1. Would it be more efficient to add a column on the SALES table called [Adjusted Sales] that figures this calculation, then create a new measure Total Adjusted Sales = sum(SALES[Adjusted Sales]), or just do this calculation with a measure?
2. Whichever one is more efficient, how would I write it? The column would be in M language and the measure would be in DAX and I'm not sure how to write this formula in either.
Thanks for your help.
Anonymous I would recommend to create a column with adjusted sales and then use this new column in the measures
Adjusted Sales Column = VAR __start = LEFT ( Table[Customer], 4 ) RETURN SWITCH ( __start, "ACME", .88, "VECT", .90, "MERC", .81, 1 ) * Table[Sales]
2 Replies
- amitchandakSuper User
Anonymous ,
Try like
sumx(SALES,
Switch( True(),
left((SALES[customer]),4) = "Acme" , SALES[Sales] *.88,
left((SALES[customer]),4) = "Vect" , SALES[Sales] *.90,
left((SALES[customer]),4) = "Merc" , SALES[Sales] *.9,
SALES[Sales])
) - parry2kSuper User
Anonymous I would recommend to create a column with adjusted sales and then use this new column in the measures
Adjusted Sales Column = VAR __start = LEFT ( Table[Customer], 4 ) RETURN SWITCH ( __start, "ACME", .88, "VECT", .90, "MERC", .81, 1 ) * Table[Sales]