Forum Discussion

Chandrashekar's avatar
Chandrashekar
Resolver III
6 months ago
Solved

DAX : Based on condition on multi column

Hello,

 

Sorry it is refering to the below post

Link: Solved: Column Formula : Based on condition - Microsoft Fabric Community

 

Hello,

Need help in DAX for below table. I am looking for formula based on column2.

If Number continuous and if it contains De then only formula should get 1 else 0.

For Ex: S1 - We have two occurrence and also we have De in it. So formula should get 1.
S2 - We have two occurrence but we do not have De in it so formula should get 0

Column2Column2Column3Expected Output
S1S1-Adad1
S1S1-Dede1
S2S2-Adad0
S2S2-SeSe0
S4S4-adad1
S4S4-SeSe1
S4S4-dede1

 

Regards,

Chandrashekar B

  • FreemanZ's avatar
    FreemanZ
    6 months ago

    seems you are trying to write a measure, try like:

     

    Column = 

    VAR _table =

    FILTER(

        ALLSELECTED(data),

        data[Column1]=MAX(data[Column1])

    )

    VAR _check1 = COUNTROWS(_table) > 1

    VAR _check2 = 

    COUNTX(

        _table,

       IF(CONTAINSSTRING(data[Column2], "de"), 1)

    ) > 0

    VAR _result = IF(_check1 && _check2, 1, 0)

    RETURN _result

6 Replies

    • Chandrashekar's avatar
      Chandrashekar
      Resolver III

      Hello,

      If Number continuous and if it contains De then only DAX should get 1 else 0.

       

      Hope this clear now.

      For Ex: S1 - We have two occurrence and also we have De in it. So formula should get 1.
      S2 - We have two occurrence but we do not have De in it so formula should get 0

       

      Regards,

      Chandrashekar B

       

      • FreemanZ's avatar
        FreemanZ
        Super User

        hi Chandrashekar , 

         

        Not sure if i really get you, you may try the following:

        Column = 
        VAR _table =
        FILTER(
            data,
            data[Column1]=EARLIER(data[Column1])
        )
        VAR _check1 = COUNTROWS(_table) > 1
        VAR _check2 = 
        COUNTX(
            _table,
            IF(CONTAINSSTRING(data[Column2], "de"), 1)
        ) > 0
        VAR _result = IF(_check1 && _check2, 1, 0)
        RETURN _result

         

        it works like: