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.
Hi All,
Consider we have a table with a list of countries and group names assigned for each county. We need to create a Flag column that will have the values Yes, No & Both.
1. When the country has the Group Name as Group 1, the flag will be Yes
2. When the country has both Group 1 & Group 2 or Group 1 & Group 3,
a. the flag will be Both for the row that contains Group 2
b. the flag will be Yes for the row that Group 1
3. In other case, the flag will be No
Country | Group Name | Flag |
AAA | Group 1 | Yes |
BBB | Group 2 | No |
CCC | Group 3 | No |
DDD | Group 1 | Yes |
DDD | Group 2 | Both |
EEE | Group 3 | No |
FFF | Group 1 | Yes |
FFF | Group 3 | Both |
GGG | Group 3 |
No
|
Can you please help in achieving the flag logic through DAX?
Thanks in advance !!
Solved! Go to Solution.
HI, @MadhumithaV_26
try below measure
Measure 4 =
var a = CALCULATE(
DISTINCTCOUNT('Table'[Group Name]),
REMOVEFILTERS('Table'[Group Name])
)
var b = SWITCH(TRUE(),
MAX('Table'[Group Name])="group 1","yes",
a=2 && OR(MAX('Table'[Group Name])="group 2",
MAX('Table'[Group Name])="group 3"),"both",
"no"
)
return b
hi @MadhumithaV_26 ,
try to add a column like:
Column =
SWITCH(
TRUE(),
[Group Name] = "Group 1", "Yes",
VAR _list =CALCULATETABLE(VALUES(data[Group Name]), ALLEXCEPT(data, data[Country]))
VAR _condition = "Group 1" IN _list && [Group Name]<>"Group 1"
RETURN _condition,
"Both", "No"
)
it worked like:
HI, @MadhumithaV_26
try below measure
Measure 4 =
var a = CALCULATE(
DISTINCTCOUNT('Table'[Group Name]),
REMOVEFILTERS('Table'[Group Name])
)
var b = SWITCH(TRUE(),
MAX('Table'[Group Name])="group 1","yes",
a=2 && OR(MAX('Table'[Group Name])="group 2",
MAX('Table'[Group Name])="group 3"),"both",
"no"
)
return b
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
37 | |
25 | |
19 | |
14 | |
8 |
User | Count |
---|---|
69 | |
48 | |
44 | |
19 | |
15 |