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
GrahamR99
Resolver I
Resolver I

Count Amount of Product's with a total of greater than 5

Hello

I am looking for a formual for a measure that will count the amount of products in a year that have a stock quantaity greater than 5.

 

So for example this is my data example

Year_PurchaseProductStock_QTY
2010Product110
2010Product24
2011Product36
2011Product420
2011Product52

 

This is what I want it to look like

Year_PurchaseStock Greater Than 5
20101
20112

 

What is the formual I need to get the Stock Greater Than 5?

 

Regards


GrahamR99

2 ACCEPTED SOLUTIONS

@GrahamR99

 

May be this one

 

=
COUNTROWS (
    FILTER (
        ALLSELECTED ( Append1[Product_Name] ),
        CALCULATE ( SUM ( Append1[QTY] ) ) > 5
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

@GrahamR99

 

=
COUNTROWS (
    FILTER (
        ALLSELECTED ( Append1[Product_Name] ),
        CALCULATE ( SUM ( Append1[QTY] ) ) > 0
            && CALCULATE ( SUM ( Append1[QTY] ) ) < 5
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

8 REPLIES 8
pbiozkan
Helper I
Helper I

Hi,

 

Formula should be written as below;

 

 

Calculate(count(your table name(product), filter(your table name, table name [stock qty]>5)

Hello

This is my formual I have.

CALCULATE(Count(Append1[Product_Name]),filter(Append1, Append1[QTY]>5))

but it does not work.

 

PowerBI_Matrix.jpg

 

I am expecting for 2010 to be 1 and 2011 to be 0.

 

SKU is the total about of products for that year, so products with greater than 5 should be less than the SKU, as you can see from my table I have more for Grater than 5.

 

Regards

 

GrahamR99

@GrahamR99

 

May be this one

 

=
COUNTROWS (
    FILTER (
        ALLSELECTED ( Append1[Product_Name] ),
        CALCULATE ( SUM ( Append1[QTY] ) ) > 5
    )
)

Regards
Zubair

Please try my custom visuals

Hello

COUNTROWS ( FILTER ( ALLSELECTED ( Append1[Product_Name] ), CALCULATE ( SUM ( Append1[QTY] ) ) > 5 ) )

 

That works, thank you.

 

How do I do less than 5?

 

I change it to this

COUNTROWS ( FILTER ( ALLSELECTED ( Append1[Product_Name] ), CALCULATE ( SUM ( Append1[QTY] ) ) < 5 ) )

 

but that did not work, and I don't know why?

 

Regards

 

GrahamR99

This is strange

May be use <=

Regards
Zubair

Please try my custom visuals

Hi

I tried <= but the number is still massive.

 

Here is the new figure when I change the formual to;

COUNTROWS(FILTER(ALLSELECTED(Append1[Product_Name]),CALCULATE(SUM(Append1[QTY])) <= 5))

PowerBI_Matrix_part2.jpg

Why is it such a big number for the less than 5?

 

I think it is counting all the zero amounts, how do I take them out so that its greater than 0 but less than 5?

 

Regards

 

GrahamR99

 

 

@GrahamR99

 

=
COUNTROWS (
    FILTER (
        ALLSELECTED ( Append1[Product_Name] ),
        CALCULATE ( SUM ( Append1[QTY] ) ) > 0
            && CALCULATE ( SUM ( Append1[QTY] ) ) < 5
    )
)

Regards
Zubair

Please try my custom visuals

Thank you, for all your help. Smiley Very Happy 

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.