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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jeongkim
Helper IV
Helper IV

Multiple condition function in Dax

Hi guys,

 

Can anyone help me how to make new column using measure to lookup the Grade below. 

Type A, the bigger the Green is, and Type B is opposite. 

 

So how can I run IF or Switch function?

The function I tried seems wrong,,

 

jeongkim_2-1669622226871.png

 

jeongkim_0-1669622014519.png

 

jeongkim_1-1669622085471.png

 

Thanks in advance. 

Kim

 

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

Hi @jeongkim ,

You can create a calculated column as below in the table 'SKT' to get it:

Icon Grade = 
SWITCH (
    TRUE (),
    'SKT'[Type] = 1
        && 'SKT'[Value] < 'SKT'[Red], 1,
    'SKT'[Type] = 1
        && 'SKT'[Value] > 'SKT'[Red]
        && 'SKT'[Value] <= 'SKT'[Light-Red], 2,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Light-Green], 4,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Green], 5,
    'SKT'[Type] = -1
        && 'SKT'[Value] >= 'SKT'[Red], 1,
    'SKT'[Type] = -1
        && 'SKT'[Value] < 'SKT'[Red]
        && 'SKT'[Value] >= 'SKT'[Light-Red], 2,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Light-Green], 4,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Green], 5,
    3
)

yingyinr_0-1669688178573.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

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @jeongkim ,

You can create a calculated column as below in the table 'SKT' to get it:

Icon Grade = 
SWITCH (
    TRUE (),
    'SKT'[Type] = 1
        && 'SKT'[Value] < 'SKT'[Red], 1,
    'SKT'[Type] = 1
        && 'SKT'[Value] > 'SKT'[Red]
        && 'SKT'[Value] <= 'SKT'[Light-Red], 2,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Light-Green], 4,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Green], 5,
    'SKT'[Type] = -1
        && 'SKT'[Value] >= 'SKT'[Red], 1,
    'SKT'[Type] = -1
        && 'SKT'[Value] < 'SKT'[Red]
        && 'SKT'[Value] >= 'SKT'[Light-Red], 2,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Light-Green], 4,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Green], 5,
    3
)

yingyinr_0-1669688178573.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.

also how can I add another condition? if the Value is (blank) then just leave it blank without grading? 

 

Hi  @jeongkim ,

You can update the formula of calculated column as below to get it:

Icon Grade =
SWITCH (
    TRUE (),
    ISBLANK ( 'SKT'[Value] ), BLANK (),
    'SKT'[Type] = 1
        && 'SKT'[Value] < 'SKT'[Red], 1,
    'SKT'[Type] = 1
        && 'SKT'[Value] > 'SKT'[Red]
        && 'SKT'[Value] <= 'SKT'[Light-Red], 2,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Light-Green], 4,
    'SKT'[Type] = 1
        && 'SKT'[Value] >= 'SKT'[Green], 5,
    'SKT'[Type] = -1
        && 'SKT'[Value] >= 'SKT'[Red], 1,
    'SKT'[Type] = -1
        && 'SKT'[Value] < 'SKT'[Red]
        && 'SKT'[Value] >= 'SKT'[Light-Red], 2,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Light-Green], 4,
    'SKT'[Type] = -1
        && 'SKT'[Value] <= 'SKT'[Green], 5,
    3
)

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.

Thank you so much! It is simpler and now working 🙂

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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