cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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,,

Kim

1 ACCEPTED SOLUTION
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
)``````

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.
4 REPLIES 4
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
)``````

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.
Helper IV

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

Community Support

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.
Helper IV

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

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors