cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ibesmond
Helper II
Helper II

counting values with conditions using DAX

I feel like this is a very simple questions, but can't seem to get it to work.  I'm trying to do a countif in essence. 

 

I basically want to summarize the number of machines needed to make certain products.

 

ProductNo of Machines
Biscotti3
Cream Donut7
Caramel3
Chocolate cookies7
Double Chocolate3
Chocolate Donut3
Custard Donut7
Deluxe Cookies3

 

I can do that using: 

No of Machines = COUNTROWS('Target Speeds' )
 
However I want to isolate the measure outside of the views context, so I can use it in a DAX formula.
So if I bring machine into the visual I still get the same results.
 
ProductMachineNo of Machines
BiscottiJam Machine3
BiscottiPressing Machine3
BiscottiSprinkling Machine3
Cream DonutBoxing Machine7
Cream DonutFilling Machine7
Cream DonutForming Machine7
Cream DonutHeating Machine7
Cream DonutMixing Machine7
Cream DonutTopping Machine7
Cream DonutPackaging Heat Machine7
CaramelJam Machine3
CaramelPressing Machine3
CaramelSprinkling Machine3
Chocolate cookiesBoxing Machine7
Chocolate cookiesFilling Machine7
Chocolate cookiesForming Machine7
Chocolate cookiesHeating Machine7
Chocolate cookiesMixing Machine7
Chocolate cookiesTopping Machine7
Chocolate cookiesPackaging Heat Machine7
Double ChocolateJam Machine3
Double ChocolatePressing Machine3
Double ChocolateSprinkling Machine3
Chocolate DonutJam Machine3
Chocolate DonutPressing Machine3
Chocolate DonutSprinkling Machine3
Custard DonutBoxing Machine7
Custard DonutFilling Machine7
Custard DonutForming Machine7
Custard DonutHeating Machine7
Custard DonutMixing Machine7
Custard DonutTopping Machine7
Custard DonutPackaging Heat Machine7
Deluxe CookiesJam Machine3
Deluxe CookiesPressing Machine3
Deluxe CookiesSprinkling Machine3
 
 Any advice?
1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

So you want to get the table to ignore every filter context but product? Here is an example on how to do that:

Data:

ValtteriN_0-1642796228074.png


Dax:

Measure 13 = CALCULATE(COUNTROWS(NumberOfMachines),ALLEXCEPT(NumberOfMachines,NumberOfMachines[Product]))
 
End result:
ValtteriN_1-1642796331869.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





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

Hi,

So you want to get the table to ignore every filter context but product? Here is an example on how to do that:

Data:

ValtteriN_0-1642796228074.png


Dax:

Measure 13 = CALCULATE(COUNTROWS(NumberOfMachines),ALLEXCEPT(NumberOfMachines,NumberOfMachines[Product]))
 
End result:
ValtteriN_1-1642796331869.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





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

Proud to be a Super User!




@ValtteriN 

I think that is going to work.  I will have to check once I get to writing the DAX formula.  Thank you for the help.

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!