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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
OneData
New Member

Power BI version of 'Case When' using "Switch" Function

Hi guys - i'm new to dax and am having a bit oftrouble with what I would like to think should be something simple.

 

Essentially i have paramaters for each bucket listed below and I want those to dynammically fall into one column. I think I've done most of the hard part but I can't seem to put the right measure together. - Is this possible with a measure? I don't think i can add a numeric parameter in the calucalted column in power query so i'm kinda stuck here. Hopefully this is as simple for one of you as it would be for me in sql.

 

What am i doing wrong here?

 

ENLR Delta =
SWITCH(
    TRUE(),
    FILTER('Application','Application'[Fico Range] = "640-679"),([Net Loss Ratio] - [640-679 Value]),
    FILTER('Application]','Application'[Fico Range] = "680-699"),([Net Loss Ratio] - [680-699 Value]),
    FILTER('Application','Application'[Fico Range] = "700-739"),([Net Loss Ratio] - [700-739 Value]),
    FILTER('Application','Application'[Fico Range] = "740-799"),([Net Loss Ratio] - [740-799 Value]),
    FILTER('Application','Application'[Fico Range] = "800+"),([Net Loss Ratio] - [800+ Value]),
    0
)
1 ACCEPTED SOLUTION
OneData
New Member

Fixed it - looks like instead of filter - using contains worked just fine for me - hope this helps someone in the future!

 

ENLR Delta =
SWITCH(
    TRUE(),
    CONTAINS('Application','Application'[Fico Range] = "640-679"),([Net Loss Ratio] - [640-679 Value]),
    CONTAINS('Application]','Application'[Fico Range] = "680-699"),([Net Loss Ratio] - [680-699 Value]),
    CONTAINS('Application','Application'[Fico Range] = "700-739"),([Net Loss Ratio] - [700-739 Value]),
    CONTAINS('Application','Application'[Fico Range] = "740-799"),([Net Loss Ratio] - [740-799 Value]),
    CONTAINS('Application','Application'[Fico Range] = "800+"),([Net Loss Ratio] - [800+ Value]),
    0
)

View solution in original post

3 REPLIES 3
OneData
New Member

Fixed it - looks like instead of filter - using contains worked just fine for me - hope this helps someone in the future!

 

ENLR Delta =
SWITCH(
    TRUE(),
    CONTAINS('Application','Application'[Fico Range] = "640-679"),([Net Loss Ratio] - [640-679 Value]),
    CONTAINS('Application]','Application'[Fico Range] = "680-699"),([Net Loss Ratio] - [680-699 Value]),
    CONTAINS('Application','Application'[Fico Range] = "700-739"),([Net Loss Ratio] - [700-739 Value]),
    CONTAINS('Application','Application'[Fico Range] = "740-799"),([Net Loss Ratio] - [740-799 Value]),
    CONTAINS('Application','Application'[Fico Range] = "800+"),([Net Loss Ratio] - [800+ Value]),
    0
)
FreemanZ
Super User
Super User

hi @OneData 

what contexts do you have for the measure? Or how are you going to present this measure?

Similarly to case when - it will be presented in a single column - however for each bucket i need each desired input. I was able to accomplish this in power query during etl on a another column in the dataset but this one here depends on numeric parameters so i have to figure out a measure to accomplish the "case when" scenario

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.