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

Conditional Check DAX for Indicator

Hi All,

 

We're trying to create a column using the below condition. But, it's not working for us as expected.

 

I'm having a column Indicator with values 1 and 0

 

I need to write the below condition using DAX.

If Indicator = 1 THEN "SS" ELSE IF

Indicator = 0 THEN "NS" ELSE IF

Indicator = 1 or Indicator = 0 THEN "AS"

 

I have tried the below DAX, but it's not working for me.

IF(Indicator =1 , "SS", IF(OR(Indicator=1,Indicator=0),"AS","NS"))

 

Could someone please help me here.

 

Thanking in Advance.

 

Regards,

Jesh

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Then you need to create a new dimension table and a mapping table. Something along the lines of this: 

SS1
NS0
AS1
AS0

Dimension table

1
0

Mapping table

Should look like this:
image.png


Then create a slicer on your locations in the dimension table. The filter will move through the mapping table and then filter you main table accordingly. 


Connect on LinkedIn

View solution in original post

4 REPLIES 4
AlB
Super User
Super User

Hi @Anonymous 

It would be this literally. Do note though that it does not make much sense as it is, since it will never get to the last option (If Indicator is 1 or 0 it will have been assigned already "SS" or "NS").  

Col =
IF (
    Indicator = 1,
    "SS",
    IF ( Indicator = 0, "NS", IF ( OR ( Indicator = 1, Indicator = 0 ), "AS" ) )
)

 

Anonymous
Not applicable

My Scenario is to achieve something below.

 

My dataset is having the below fields.

 

Location, Indicator

1, 1

2, 1

3, 0

4, 0

 

So, after creating the below mentioned DAX. 

 

When I click on SS, it should show me locations 1 and 2.

When I click on NS, it should show me locations 3 and 4.

When I click on AS, it should show me all the locations.

 

Thanks,

Jesh

tex628
Community Champion
Community Champion

Then you need to create a new dimension table and a mapping table. Something along the lines of this: 

SS1
NS0
AS1
AS0

Dimension table

1
0

Mapping table

Should look like this:
image.png


Then create a slicer on your locations in the dimension table. The filter will move through the mapping table and then filter you main table accordingly. 


Connect on LinkedIn
Anonymous
Not applicable

Thanks for the reply @AlB 

 

yeah, it'll never go to the last option. But we need that last option to be considered somehow.

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.