Forum Discussion

shaunguyver's avatar
shaunguyver
Helper III
8 years ago
Solved

IF statement based on filters

I have a slicer, which has 3 possible values, taken from 'Region' column in my data set.

 

  • USA
  • Europe
  • Asia

I have a card that has 'Region' as its value. Each time a region is selected in the slicer, it updates the card.

 

I want to create a measure that (logically) reads like this:

 

Measure = IF('Region'=Blank,"Global",'Region')

 

In other words, if the slicer containing 'Region' has nothing selected I want the measure to display the value 'Global'. Once a region is selected, the card displays the selected region.

 

Is this possible?

 

Thanks in advance

  • Try this, if one region selected, it will give the name of the region, if none is selected or more than one selected, it will say "Global"

     

    You have to think what you want to say in case more than one region is selected , basically out of 3 you listed, user selects 2, what you want to call it, GLOBAL? I didn't consider that in  following DAX.

     

    Measure Region = IF ( HASONEVALUE( Table[Region] ), VALUES( Table[Region]), "GLOBAL" ) 

     

2 Replies

  • Try this, if one region selected, it will give the name of the region, if none is selected or more than one selected, it will say "Global"

     

    You have to think what you want to say in case more than one region is selected , basically out of 3 you listed, user selects 2, what you want to call it, GLOBAL? I didn't consider that in  following DAX.

     

    Measure Region = IF ( HASONEVALUE( Table[Region] ), VALUES( Table[Region]), "GLOBAL" ) 

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can do this by using ISFILTERED Function

     

     

    Dynamic Region Value = SWITCH(TRUE(), ISFILTERED(Sheet1[Region]),SELECTEDVALUE(Sheet1[Region]),
                                 "Global"
    )

    OR Dynamic Region Value = IF(ISFILTERED(Sheet1[Region]),SELECTEDVALUE(Sheet1[Region]),"Global")