Forum Discussion
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
| Column2 | Column2 | Column3 | Expected Output |
| S1 | S1-Ad | ad | 1 |
| S1 | S1-De | de | 1 |
| S2 | S2-Ad | ad | 0 |
| S2 | S2-Se | Se | 0 |
| S4 | S4-ad | ad | 1 |
| S4 | S4-Se | Se | 1 |
| S4 | S4-de | de | 1 |
Regards,
Chandrashekar B
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
- FreemanZSuper User
Hi Chandrashekar ,
number continuous and two occurance are two things, could you elaborate this point?
- ChandrashekarResolver 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 0Regards,
Chandrashekar B
- FreemanZSuper 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 _resultit works like: