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
Kr1v3L1337
Frequent Visitor

Average number of item sold per store

Hi!

 

I want to calculate the average number of SKUs (items) sold per store

In my data hundreds of stores with thousands of products with sales.

 

I have success with calculating the number using this measure, but it is - very - slow.

 

Is there anyway to speed up this measure or structure it in another manner?

 

 

 

AVG SKUs Sold per Store = 
var _tab = SUMMARIZE(Sales,
                    Sales[Store Number],
                    "SKU",
                    CALCULATE(
distinctcount('Item'[Item Number]),
  FILTER('Item','Item'[Category] <> "Internal" && 'Item'[Category] <> "Unknown" && 
             'Item'[Subcategory] <> "Recycle" && [Qty] > 0)
)
)
return

AVERAGEX(_tab,[sku])

 

 

 

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Kr1v3L1337 

 

I'm thinking a "related distinct count" style measure would work well here.

 

Here's one measure that might work, based on the pattern from the DAX Patterns page above.

I've assumed that [Qty] > 0 would only be true if Items actually appear in the Sales table.

AVG SKUs Sold per Store =
CALCULATE (
    AVERAGEX (
        VALUES ( Sales[Store Number] ),
        CALCULATE (
            VAR ItemsFromSales =
                SUMMARIZE ( Sales, 'Item'[Item Number] )
            RETURN
                SUMX ( ItemsFromSales, 1 )
        )
    ),
    KEEPFILTERS ( NOT 'Item'[Category] IN { "Internal", "Unknown" } ),
    KEEPFILTERS ( 'Item'[Subcategory] <> "Recycle" )
)

 Does this measure return correct results, and does it perform any better than your original measure?

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @Kr1v3L1337 

 

I'm thinking a "related distinct count" style measure would work well here.

 

Here's one measure that might work, based on the pattern from the DAX Patterns page above.

I've assumed that [Qty] > 0 would only be true if Items actually appear in the Sales table.

AVG SKUs Sold per Store =
CALCULATE (
    AVERAGEX (
        VALUES ( Sales[Store Number] ),
        CALCULATE (
            VAR ItemsFromSales =
                SUMMARIZE ( Sales, 'Item'[Item Number] )
            RETURN
                SUMX ( ItemsFromSales, 1 )
        )
    ),
    KEEPFILTERS ( NOT 'Item'[Category] IN { "Internal", "Unknown" } ),
    KEEPFILTERS ( 'Item'[Subcategory] <> "Recycle" )
)

 Does this measure return correct results, and does it perform any better than your original measure?

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

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.