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 August 31st. Request your voucher.

Reply
MichaelaMul
Helper III
Helper III

CountIf Dax Function- How to Fix it?

Hi everyone,

 

I have a formula that says whether a product is at risk based on the following measure. I would like to make a new measure that I could put in a card to measure the total number of products at risk for a specific brand, however I have tried a few ways and it isn't showing correctly. I would have slicers that although me to filter by time and geography.

 

Here's the current formula that says if it is at risk or not:

 

Vol - Risk Level (Bottom 20%) = if((CALCULATE([Volume per $MM Rank])/[# of Products Volume])>0.80,"AT RISK", "--")

 

And here are the other measures that go with it:

 

Volume per $MM Rank = 
IF (
    NOT ( ISBLANK ( Distribution[Total Volume per $MM per item] ) ),
    RANKX (
        FILTER ( ALLSELECTED ( Distribution[Product] ), NOT ( ISBLANK ( [Total Volume per $MM per item] ) ) ),
        [Total Volume per $MM per item]
    )
)
# of Products Volume = CALCULATE(DISTINCTCOUNT(Distribution[Product]),ALL(Distribution[Product]),Distribution[ACV Weighted Distribution] > 2.5)

 

This is the formula that I have tried and it isn't working.

 

COUNT RISK = CALCULATE(COUNTA(Distribution[Product]), filter(ALLSELECTED('Distribution'),'Distribution'[Calculate Risk Volume]= 1))

 

 

I think I need to make the Risk Level Calculation into a Column but when I do that, it doesn't work, this is the column measurement I made:

 

Column = COUNTX
(
FILTER
(
VALUES
( 'Distribution'[Product]), CALCULATE([Volume per $MM Rank]/[# of Products Volume])>0.8),'Distribution'[Product])

 

Also below is sample data, along with the results when I added the Column calculation.

GeographyTimeProductVolume per $MM per ItemACV Weighted DistributionSEGMENTBRANDSIZEColumn
STORE KLatest 4 WeeksBRAND ABC OAT ALMOND SWEETENED ORIGINAL PLANT A/O 52 OZ0.0987.09ALMONDBRAND ABC52 OZ1
STORE KLatest 13 WeeksBRAND ABC OAT ALMOND SWEETENED ORIGINAL PLANT A/O 52 OZ0.2789.72ALMONDBRAND ABC52 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED EXTRA CREAMY PLANT FULL 64 OZ 0.3668.47ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED EXTRA CREAMY PLANT FULL 64 OZ0.1264.91ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED REDUCED SUGAR VANILLA PLANT A/O 64 OZ0.2093.33ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED REDUCED SUGAR VANILLA PLANT A/O 64 OZ0.6593.67ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED ORIGINAL PLANT A/O 64 OZ1.5099.25ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED ORIGINAL PLANT A/O 64 OZ0.4699.09ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND UNSWEETENED ORIGINAL PLANT A/O 64 OZ0.8699.04ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND UNSWEETENED ORIGINAL PLANT A/O 64 OZ2.7499.20ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED BANANA PLANT A/O 64 OZ0.5290.13ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED BANANA PLANT A/O 64 OZ0.1689.82ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND UNSWEETENED VANILLA PLANT A/O 64 OZ2.3498.99ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND UNSWEETENED VANILLA PLANT A/O 64 OZ0.7498.88ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED HONEY VANILLA PLANT A/O 64 OZ0.3289.07ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED HONEY VANILLA PLANT A/O 64 OZ1.0289.40ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED VANILLA PLANT A/O 64 OZ1.4299.06ALMONDBRAND ABC64 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED VANILLA PLANT A/O 64 OZ0.4398.70ALMONDBRAND ABC64 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND UNSWEETENED VANILLA PLANT A/O 96 OZ1.7896.39ALMONDBRAND ABC96 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND UNSWEETENED VANILLA PLANT A/O 96 OZ0.5296.15ALMONDBRAND ABC96 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED ORIGINAL PLANT A/O 96 OZ0.2691.13ALMONDBRAND ABC96 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED ORIGINAL PLANT A/O 96 OZ0.9091.98ALMONDBRAND ABC96 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND SWEETENED VANILLA PLANT A/O 96 OZ1.4193.36ALMONDBRAND ABC96 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND SWEETENED VANILLA PLANT A/O 96 OZ0.4192.86ALMONDBRAND ABC96 OZ1
STORE KLatest 4 WeeksBRAND ABC ALMOND UNSWEETENED ORIGINAL PLANT A/O 96 OZ0.6696.89ALMONDBRAND ABC96 OZ1
STORE KLatest 13 WeeksBRAND ABC ALMOND UNSWEETENED ORIGINAL PLANT A/O 96 OZ2.2497.43ALMONDBRAND ABC96 OZ1
2 REPLIES 2
Anonymous
Not applicable

Hi @MichaelaMul ,

Based on the information you have provided, can you provide your desired output. This would allow us to better reproduce and solve the problem you are experiencing.

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MichaelaMul
Helper III
Helper III

I was able to make this measure work, however I'm wondering if there is a workaround so that I don't need to make an individual one for each brand I want a card for.  For example, I would want to look at BRAND DEF for a Cashew Category. When I didn't include the filter and filtered it separately, it changed the # of products, because it was filtered by the brand instead of the segment, and as a result changed the number of products at risk. 

 

Count Risk Vol = 
COUNTROWS(
		FILTER(
			ADDCOLUMNS(SUMMARIZECOLUMNS(
				'Distribution'[Product]),
				"risk", CALCULATE([Vol - Risk Level (Bottom 20%)])
				), 
			[Vol - Risk Level (Bottom 20%)] = "AT RISK"
			&& CONTAINSSTRING(Distribution[Product], "BRAND ABC")
	))

 

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.

Top Solution Authors