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
Anonymous
Not applicable

DAX formula for multiple conditions

Hi there 

 

I need help with DAX formula for the following logic

 

IF Income is in Group1 & Income > x, then [VALUE],

IF Income is in Group2 & Income > x, then [VALUE], 

IF Income is in Group3 & Income > x, then [VALUE]

 

 

 

 

Your assistance would be greatly appreciated.

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

You can try formul like below:

Result =
IF (
    'Table'[Income] > 1500,
    IF (
        'Table'[Group] = "Group1",
        "result1",
        IF (
            'Table'[Group] = "Group2",
            "result2",
            IF ( 'Table'[Group] = "Group3", "result3" )
        )
    ),
    "<1500"
)

vhenrykmstf_0-1661245323816.png

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

You can try formul like below:

Result =
IF (
    'Table'[Income] > 1500,
    IF (
        'Table'[Group] = "Group1",
        "result1",
        IF (
            'Table'[Group] = "Group2",
            "result2",
            IF ( 'Table'[Group] = "Group3", "result3" )
        )
    ),
    "<1500"
)

vhenrykmstf_0-1661245323816.png

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

Anonymous
Not applicable

Thank you very much,

however when I run this I receive a "Expressions that yield variant data-type cannot be used to define calculated columns" error.

 

Any suggestions on how to get around this?

amitchandak
Super User
Super User

@Anonymous , You Can create a  new column using Switch true

 

Switch(True() ,

[Income Group] = "Group1" && [Income] < 1000 , "Value1" ,

[Income Group] = "Group2" && [Income] < 1000 , "Value2" ,

[Income Group] = "Group3" && [Income] < 1000 , "Value3"

)

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.