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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Finding in a group of rows if value A is present but value B is not present DAX

HI All,

I am facing a situation where I need to find in a group of rows if a value A is present but value B is absent. Here is the input, the group is of Order ID.

OrderIdEntryIDValue
1001A
1002B
1013A
1014A

 

Output:

OrderIdEntryIDValueA not B flag
1001AFalse
1002BFalse
1013ATrue
1014ATrue

 

Please help. Thanks in advance.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try a new column like

 

new column =
var _A = countx(filter(Table, [OrderId] = earlier([OrderId]) && [Value] = "A"), [Value])
var _B = countx(filter(Table, [OrderId] = earlier([OrderId]) && [Value] = "B"), [Value])
return
if(not(isblank(_A)) && isblank(_A), true(), false())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Test = not(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[OrderId]=EARLIER(Data[OrderId])&&Data[Value]="B"))>0)

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

Test = not(CALCULATE(COUNTROWS(Data),FILTER(Data,Data[OrderId]=EARLIER(Data[OrderId])&&Data[Value]="B"))>0)

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Anonymous , Try a new column like

 

new column =
var _A = countx(filter(Table, [OrderId] = earlier([OrderId]) && [Value] = "A"), [Value])
var _B = countx(filter(Table, [OrderId] = earlier([OrderId]) && [Value] = "B"), [Value])
return
if(not(isblank(_A)) && isblank(_A), true(), false())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandakThanks this worked. Only changed I did was to modify the return statement as it was only considering A.

Anonymous
Not applicable

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.