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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Attrywa
Frequent Visitor

Check if value exists in group

Hello everyone!
I need some help in case below:
There are two tables A and B:

Attrywa_0-1716299871391.png

And I would need to create an additional flag in dax (1/0) -  if the LogGroup from table B contains LogKey = 124 then mark whole group as 1 (and therefore whole customer as 1) otherwise mark as 0

The logic for this in SQL would be like: 
max( case when B.LogKey = 124 then 1 else 0 end ) OVER (PARTITION BY A.Customer) as Flag

 

 

 

THANK YOU ! 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @Attrywa ,

 

Please try:

 

Create a calculated column in Table A:

Flag =
VAR CurrentGroup = 'Table A'[LogGroupKey]
VAR LogKeyCheck = CALCULATE(
     MAXX(
         RELATEDTABLE('Table B'),
         IF('Table B'[LogKey] = 124, 1, 0)
     ),
     FILTER(
         'Table B',
         'Table B'[LogGroupKey] = CurrentGroup
     )
)
RETURN IF(LogKeyCheck = 1, 1, 0)

 

The page effect is as follows:

vhuijieymsft_0-1716341156296.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

ryan_mayu
Super User
Super User

@Attrywa 

you can create a column

Column = if(ISBLANK( maxx(FILTER(TableB,TableB[LogKey]=124&&TableA[LogGroupKey]=TableB[LogGroupKey]),TableB[LogKey])),0,1)
 
11.PNG
or a measure
Measure =
if(ISBLANK(maxx(FILTER(all(TableB),'TableB'[LogGroupKey]=max('TableA'[LogGroupKey])&&'TableB'[LogKey]=124),TableB[LogKey])),0,1)
 
12.PNG
 
pls see the attachment below




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
ryan_mayu
Super User
Super User

@Attrywa 

you can create a column

Column = if(ISBLANK( maxx(FILTER(TableB,TableB[LogKey]=124&&TableA[LogGroupKey]=TableB[LogGroupKey]),TableB[LogKey])),0,1)
 
11.PNG
or a measure
Measure =
if(ISBLANK(maxx(FILTER(all(TableB),'TableB'[LogGroupKey]=max('TableA'[LogGroupKey])&&'TableB'[LogKey]=124),TableB[LogKey])),0,1)
 
12.PNG
 
pls see the attachment below




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

Proud to be a Super User!




Anonymous
Not applicable

Hi @Attrywa ,

 

Please try:

 

Create a calculated column in Table A:

Flag =
VAR CurrentGroup = 'Table A'[LogGroupKey]
VAR LogKeyCheck = CALCULATE(
     MAXX(
         RELATEDTABLE('Table B'),
         IF('Table B'[LogKey] = 124, 1, 0)
     ),
     FILTER(
         'Table B',
         'Table B'[LogGroupKey] = CurrentGroup
     )
)
RETURN IF(LogKeyCheck = 1, 1, 0)

 

The page effect is as follows:

vhuijieymsft_0-1716341156296.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.