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
Torudd-55
Frequent Visitor

DAX formula

Hi!

 

Can someone help me with an, hopefully, easy problem. I would like to write a DAX formula that selects all of the orders that contains the vendor "milk" whitout only showing the orderno and the specifik items related to that vendor.

 

So the result, when looking at the table below, should only remove the order "2" from the visualization.

 

Thanks in advance!

 

order.noitem.novendor
123water
 24milk
 25milk
 26 water
223 water
 26water
328 tea
 29 soda
 30sparkling water
 24 milk
424 milk
 29soda
525 milk
 26 water
629 soda
 25 milk
 24 milk
1 ACCEPTED SOLUTION

Hi @Torudd-55 

 

I just got you, could you please check if you'd like to get this one?

HasMilk = CALCULATE(MAX(Table3[order.no]),FILTER(ALL(Table3),[vendor]="milk"),VALUES(Table3[order.no]))

06.PNG

Then you can filter the measure without blank to get the final results.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @Torudd-55 

 

Let me know if you'd like to get below results:

1. I used your data and fill down the first column:

03.PNG

2.  Use the filter panel:

04.PNG

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Hi @v-diye-msft 

 

I have used the filter panel but just as in your case the other items won't show, only the ones with the vendor "milk". 

 

I want all of the items whitin the order to show if the order contains one item with the vendor "milk".

Hi @Torudd-55 

 

I just got you, could you please check if you'd like to get this one?

HasMilk = CALCULATE(MAX(Table3[order.no]),FILTER(ALL(Table3),[vendor]="milk"),VALUES(Table3[order.no]))

06.PNG

Then you can filter the measure without blank to get the final results.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

What worked for me was to create a calculated column in the table (I called my "Orders") - you'll need to do a fill-down on the order.no so you have the order number in each row - that looks at the current order number for each row and looks to see if there's a record that has a vendor of "milk" (I had to do some trimming to get rid of leading/trailing spaces).  Then you just need to filter on HasMilk <> False.

 

HasMilk =
VAR _currentOrder = Orders[order.no]
VAR _currentRows = FILTER(Orders, Orders[order.no] = _currentOrder && TRIM(Orders[vendor]) = "milk")
VAR _milkCount = COUNTROWS(_currentRows) <> 0
RETURN _milkCount
 
Hope that helps.  If you find that this answers your question please consider making it as "solved".
 
Eric
 

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.