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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.