Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Using IF IN Operator

Hi,

I tried the following dax which works using calculate, hwow to simply by using only If statement using IN operator

aps=CALCULATE(If(countrows(Pop)>0,"Yes","No"),Pop[city] IN {"Arizona","Arkansas","California","Colorado"})

I need something like below:

If(Pop[city] IN {"Arizona","Arkansas","California","Colorado"},"Yes","No")
I tried this way but column(Pop[city]) is not showing in DAX editor.

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

     

    Create a Measure.

     

    Measure = IF ( MAX(Pop[city])) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

     

     

    Incase you want to create a Calculated Column

    Column = IF (Pop[city] IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

     

     

    Regards,

    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Create a Measure.

     

    Measure = IF ( MAX(Pop[city])) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

     

     

    Incase you want to create a Calculated Column

    Column = IF (Pop[city] IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

     

     

    Regards,

    Harsh Nathani

    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the fast response.

       

      Measure = IF ( MAX(Pop[city]) IN { "Arizona","Arkansas","California","Colorado"},"Yes","No")

      This measure works fine as long as in in table which i need to display on table.

       

      I just test this one on "Card" visualization which gives "No". Out of 50 cities, i am checking only 4 cities.  The last city in the column is "Wyoming". 

      When is used  to test : Measure2 = max(Pop[city]) Then "card" Visualization is display Last city "Wyoming".

       

      My concern is as long as there is city value exist then display "Yes" either on the table or on the card.

       

      Thanks.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Can you share sample data, your data model and your expected output to help you on this.

         

        Regards,

        Harsh Nathani

        Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)