Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JuliaYebra
Helper III
Helper III

Customer 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, more than 250 units.

 

It was easy to do it for a particular month:

Category = if [units] <100 then "<100" else if [units] <250 then "100-250" else ">250"

 

But if I want to do it for the whole year I can't find the better way to solve that as I couldn't use the YTD function in M language.

 

For example, this customer it would be at the "<100" category from january to march, but then it would be at the "100-250" from april to june, and finally it would end up at the ">250" category.

 

Segmentation.png

 

I'm afraid it's really simple but I couldn't do it. Please I need help!

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@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-...

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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@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-...

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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vanessafvg
Super User
Super User

what 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" )





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.