Forum Discussion
JuliaYebra
Helper III
9 years agoCustomer dynamic segmentation
Hello. I'm just trying to do some dynamic segmentation of customers according to the units they buy. Very simple in theory. The category would be: less than 100 units, between 100 and 250 units, ...
- Anonymous9 years ago
JuliaYebra,
Create YTD measure using DAX following the tips in the blog below.
https://www.mssqltips.com/sqlservertip/4841/calculating-mtd-qtd-ytd-running-and-cumulative-total-in-power-bi/
Then create a column in your table using DAX rather than M, you can also use SWITCH function as other's post to create the column.
Column = IF([YTDMeasure]<100,"<100",(IF([YTDMeasure]<250,"100-250",">250")))
Regards,
Lydia
vanessafvg
Community Champion
9 years agowhat about the switch statement? if you create it as a measure it should just roll up at whatever date level you look at it i think
ie
SWITCH (TRUE (),
AND ( unit >= 0, unit <= 100 ), "<100",
keep going as above until last one
"na" )