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

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.

Reply
webportal
Impactful Individual
Impactful Individual

How to create a table (or list) with the order codes of orders with both products

I have a "Transactions" table with the following structure:

 

ID | Product | OrderCode |  Value

1   |   8         | ABC             | 100

2   |   5         | ABC             | 150

3   |   4         | ABC            |  80

4   |   5         | XPT             | 100

5   |   6         | XPT             | 100

6   |   8         |  XPT             | 100

7   |   5         | XYZ              |  100

8   |   8         |  UYI              | 90

 

How do I create a table (or list) with the order codes of orders with both products 5 and 8?

 

In the example above it should be orders ABC and XPT.

 

Thank you!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

I might look at this in more detail but at first glance it looks very similar to the problem that I wrote my "Patient Cohort" Quick Measure to solve.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Patient-Cohort/m-p/391883

 

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

9 REPLIES 9
v-yulgu-msft
Employee
Employee

Hi @webportal,

 

You can new a calculated table:

New Table =
FILTER (
    Table,
    CALCULATE (
        DISTINCTCOUNT ( Table[Product] ),
        FILTER ( ALLEXCEPT ( Table, Table[OrderCode] ), Table[Product] = 5 )
    )
        + CALCULATE (
            DISTINCTCOUNT ( Table[Product] ),
            FILTER ( ALLEXCEPT ( Table, Table[OrderCode] ), Table[Product] = 8 )
        )
        >= 2
)

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Ashish_Mathur
Super User
Super User

Hi,

 

What is your expected result?


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

@Ashish_Mathur
Similar to the solution presented above, although the visual should be a table instead of a comma separated string.
Greg_Deckler
Super User
Super User

I might look at this in more detail but at first glance it looks very similar to the problem that I wrote my "Patient Cohort" Quick Measure to solve.

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Patient-Cohort/m-p/391883

 

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler this works very well, thanks for sharing!

But how to return tmpTable3 as a table instead of a card with a comma separated string? If there are many patients in the cohort (orders in my case) the card won't do.

Thank you so much for helping!

Stachu
Community Champion
Community Champion

@webportal
if you use UNICHAR(10) (line break) instead of "," as separator it CONCATENATEX it should improve readability, still it's not a table per se. just a workaround



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

webportal
Impactful Individual
Impactful Individual

Good idea, thanks a lot!
🙂

I will look into that. I really, really, really wish that table and matrix visualizations accepted a measure that returned a table as a valid input. That would solve sooooooo many problems...


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi,
Yes, this is very similar to the problem I have in hands.
Your solution seems perfect, although I'll need a bit of thinking to fully understand it.
Thanks a lot for sharing this!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors