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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JamesMF1982
Frequent Visitor

Categorise values in a measure not a column

Hi,

 

I want to be able to categorise dates into a number of categories and then put them into a pie chart, now I know the best way is to put them into a column, however I am pulling a dataset that isn't able to modified by myself and would be chargeable by our third party and so a measure would be free.

 

I worked what the column calculation would be:

 

EnquiryDaysToConvert = if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=10,"0 - 10 days",
if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=15,"11 - 15 days",
if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=20,"0 - 20 days",
if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=25,"21 - 25 days",
if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=30,"26 - 30 days","Over 30 days"))))),"")

 

However, I am not sure if this can be transferred to a measure. Any help would be amazing thank you

 

James

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @JamesMF1982 

According to your description, you want to convert the calculated column to the measure , you can try to use this dax:

EnquiryDaysToConvert = 
if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
SWITCH(
True(),
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=10,"0 - 10 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=15,"11 - 15 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=20,"0 - 20 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=25,"21 - 25 days",
if(DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=30,"26 - 30 days",
"Over 30 days"),blank())

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya 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-yueyunzh-msft
Community Support
Community Support

Hi , @JamesMF1982 

According to your description, you want to convert the calculated column to the measure , you can try to use this dax:

EnquiryDaysToConvert = 
if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
SWITCH(
True(),
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=10,"0 - 10 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=15,"11 - 15 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=20,"0 - 20 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=25,"21 - 25 days",
if(DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)<=30,"26 - 30 days",
"Over 30 days"),blank())

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

pi_eye
Resolver IV
Resolver IV

Hi @JamesMF1982 , 

 

There exists a "switch" statement in DAX - https://dax.guide/switch/.

For example this measure works for me:

Measure = IF(SELECTEDVALUE(Sheet1[yearmonth]) <= 202210,  
switch(TRUE,

AND (sum(Sheet1[cal1])>10, sum(Sheet1[cal1])<=20),">10 <=20",
sum(Sheet1[cal1])>40,">40",
sum(Sheet1[cal1])>30,">30")
)
For your requirement , this would look something like:
EnquiryDaysToConvert = if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
SWITCH(
DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=10,"0 - 10 days",
DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=15,"11 - 15 days",
DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)<=20,"0 - 20 days",.......))
 
HTH
 
Pi

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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