Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
Solved! Go to Solution.
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
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
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")
)
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",.......))
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |