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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Show orders that contain specific product

Hi all,

 

My table contains one row per order (i.e. I can have 3 rows, with 3 different products, but one order number)

 

I am trying to figure out a way to show orders that purchased this product (let's call it A) and any other one. For example, if I have 3 rows per order, one of which has product A, then all 3 rows would show (contains product A). If none of the rows has it, then (no product A).

 

OrderNumber Product    Result
1                       X              No A
1                       X              No A
2                       A              Has A
2                       X              Has A
2                       X              Has A
3                       X              Has A
3                       A              Has A

 

I tried smth with CALCULATE(COUNTROWS), FILTER, EARLIER but no desired result 😞 

 

Any help would be appreciated 🙂 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Anonymous

 

 

Can you try this as well?

 

Ex_contain = Var inExist =CALCULATE(COUNT(Table1[OrderNo]),FILTER(Table1,Table1[OrderNo]=EARLIER(Table1[OrderNo]) && Table1[Product]="A"))
RETURN
IF(inExist>0,"Has A","No A")

 

Thanks
Raj

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Seems similar to a problem I solved in another thread. The function you want is CONTAINS. Bottom of this thread:

 

https://community.powerbi.com/t5/Desktop/Last-3-days-average-values-per-ID-using-date/m-p/459884#M21...

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

HI @Anonymous

 

 

Can you try this as well?

 

Ex_contain = Var inExist =CALCULATE(COUNT(Table1[OrderNo]),FILTER(Table1,Table1[OrderNo]=EARLIER(Table1[OrderNo]) && Table1[Product]="A"))
RETURN
IF(inExist>0,"Has A","No A")

 

Thanks
Raj

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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