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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
marksaba
Helper II
Helper II

Distinct Count SKUs when Sales >$X

I'm looking to create a formula that allows me to count the number of Items where Sales are greater than $X. I tried the below formula but it is not working properly as it looks to the lowest level of data, which is pulled at the Item, Week, and Retailer Level. I would like this to pull back Total Sales for a SKU during the selected Time Period.

 

SKU Count Last Week >$10000 = CALCULATE(DISTINCTCOUNT('Store Inventory and Sales Last Week'[NWL Material ID]),FILTER('Store Inventory and Sales Last Week','Store Inventory and Sales Last Week'[POS Sales Last 01 Wk]>10000))
 
As can be seen below, this formula does not recognize the highlighted Materials as >$10,000 because there is not one retailer over one week that has sales >$10,000. How can I have this look at Total Sales for the Item at the level I have cut down to?  Screenshot 2023-08-30 095200.png
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @marksaba ,

 

Please try code as below to create a measure.

SKU Count Last Week >$10000 =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Store Inventory and Sales Last Week',
        'Store Inventory and Sales Last Week'[NWL Material ID],
        "Sum",
            CALCULATE (
                SUM ( 'Store Inventory and Sales Last Week'[POS Sales Last 01 Wk] )
            )
    )
RETURN
    COUNTROWS ( FILTER ( _SUMMARIZE, [Sum] > 10000 ) )

 

Best Regards,

Rico Zhou

 

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

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @marksaba ,

 

Please try code as below to create a measure.

SKU Count Last Week >$10000 =
VAR _SUMMARIZE =
    SUMMARIZE (
        'Store Inventory and Sales Last Week',
        'Store Inventory and Sales Last Week'[NWL Material ID],
        "Sum",
            CALCULATE (
                SUM ( 'Store Inventory and Sales Last Week'[POS Sales Last 01 Wk] )
            )
    )
RETURN
    COUNTROWS ( FILTER ( _SUMMARIZE, [Sum] > 10000 ) )

 

Best Regards,

Rico Zhou

 

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

Sorry for not checking the forum earlier but this works perfectly! You're a gem, thank you so much!

ray_aramburo
Super User
Super User

First create a measure like this :

Total Sales = CALCULATE(SUM(SalesColumn),ALLEXCEPT(MaterialsTable, MaterialsTable[ItemColumn]))

Then you can create a new measure like this:

Items Count = COUNTROWS(FILTER(VALUES(MaterialsTable[ItemColumn]), [Total Sales] > 10000))




Did I answer your question? Give your kudos and mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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