Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AC_DATA
Frequent Visitor

Calculated Column Based On Member Presence In Group

I need help creating a calculated column that indicates whether a certain member is in a group or not (see below):

 

GROUPMEMBER_TYPECOUNTORANGE_PRESENT
1Apple131
1Orange31
1Cherry51
1Grape111
2Cherry70
2Banana40
2Apple80
3Grape11
3Apple41
3Orange161
3Banana91
3Cherry11

 

Only Group 1 and Group 3 contain the member "Orange" so the calculated column "ORANGE_PRESENT" should contain the value 1 for all corresponding rows in those groups and Group 2 which does not contain the member "Orange" should have the corresponding values of 0.

 

Can anyone provide me with some direction on writing the DAX code to accomplish this?

1 ACCEPTED SOLUTION
AnthonyTilley
Solution Sage
Solution Sage

Try this 

 

Column =
Var Val = "ORANGE"
Var Grp = Table1[GROUP]

var check = CALCULATE(COUNT(Table1[GROUP]),Table1[GROUP]=Grp,filter(ALL(Table1),Table1[MEMBER_TYPE]=Val))
var ret = if(check=blank(),0,check)
return ret




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
AnthonyTilley
Solution Sage
Solution Sage

Try this 

 

Column =
Var Val = "ORANGE"
Var Grp = Table1[GROUP]

var check = CALCULATE(COUNT(Table1[GROUP]),Table1[GROUP]=Grp,filter(ALL(Table1),Table1[MEMBER_TYPE]=Val))
var ret = if(check=blank(),0,check)
return ret




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




mussaenda
Super User
Super User

You may want to check this thread.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.