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
v_mark
Helper V
Helper V

Convert Calc Col Switch as a measure

I was trying to convert this calculated column into a measure.
 
Task Bucket = SWITCH( TRUE(),
Task[Aged] <= 1, "<24hrs",
Task[Aged] <= 3, "<72hrs",
Task[Aged] >= 3, ">72hrs")
 
Any workaround for this type of approach? TIA


2 ACCEPTED SOLUTIONS
selimovd
Super User
Super User

Hey @v_mark ,

 

a calculated column and a measure are 2 different concepts. You cannot always convert one to another, otherwise there would not be a reason to have both.

In your case you create a value by each row. If you do that as a measure you lose abilities that a calculated column has, like filtering by that value.

 

So the real question is what exactly do you want to do?

 

Otherwise you can easily transform that into a measure, I'm just not sure if you can use it then:

Task Bucket =
SWITCH(
    TRUE(),
    MAX(Task[Aged]) <= 1, "<24hrs",
    MAX(Task[Aged]) <= 3, "<72hrs",
    MAX(Task[Aged]) >= 3, ">72hrs"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

v-yiruan-msft
Community Support
Community Support

Hi @v_mark ,

First, please make sure the field Task[Aged] will be put on your visual. Then you can create the measure as below to replace the original caculated column [Task Bucket]:

Measure =
IF (
    SELECTEDVALUE ( Task[Aged] ) <= 1,
    "<24hrs",
    IF ( SELECTEDVALUE ( Task[Aged] ) <= 3, "<72hrs", ">72hrs" )
)

yingyinr_0-1627289463858.png

Best Regards

Community Support Team _ Rena
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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @v_mark ,

First, please make sure the field Task[Aged] will be put on your visual. Then you can create the measure as below to replace the original caculated column [Task Bucket]:

Measure =
IF (
    SELECTEDVALUE ( Task[Aged] ) <= 1,
    "<24hrs",
    IF ( SELECTEDVALUE ( Task[Aged] ) <= 3, "<72hrs", ">72hrs" )
)

yingyinr_0-1627289463858.png

Best Regards

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

Hey @v_mark ,

 

a calculated column and a measure are 2 different concepts. You cannot always convert one to another, otherwise there would not be a reason to have both.

In your case you create a value by each row. If you do that as a measure you lose abilities that a calculated column has, like filtering by that value.

 

So the real question is what exactly do you want to do?

 

Otherwise you can easily transform that into a measure, I'm just not sure if you can use it then:

Task Bucket =
SWITCH(
    TRUE(),
    MAX(Task[Aged]) <= 1, "<24hrs",
    MAX(Task[Aged]) <= 3, "<72hrs",
    MAX(Task[Aged]) >= 3, ">72hrs"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
CNENFRNL
Community Champion
Community Champion

Task Bucket =
SWITCH(
    TRUE(),
    MAX( Task[Aged] ) <= 1, "<24hrs",
    MAX( Task[Aged] ) <= 3, "<72hrs",
    ">72hrs"
)

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.