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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Thigs
Helper III
Helper III

SKU Distribution Trend?

Hi all!

I'm working with a client with about 4,000 SKUs in a given year. However, it is a very seasonal business, so only about 1,500 SKUs are in store at any given time. What I need to know is how often the SKU distribution changes - every day, every week, every month? Etc. 

 

My first thought was to do a distinct count of SKUs and then trend that over time, because it is unlikely I'll have exactly the same amount of SKUs each season. But that isn't perfect - ideally I'd have some kind of a matching function and let it tell me when it stops matching, but I'm not sure how to do that with that many SKUs. Any help is appreciated!

1 ACCEPTED SOLUTION

@Thigs 

This is only part of the complete measure

Matching Percent =
VAR CurrentSKUs =
    VALUES ( 'SKU Distributions'[SKU] )
VAR PreviousSKUs =
    CALCULATETABLE (
        VALUES ( 'SKU Distributions'[SKU] ),
        'SKU Distributions'[Date Only]
            = MAX ( 'SKU Distributions'[Date Only] ) - 1
    )
RETURN
    COUNTROWS ( INTERSECT ( PreviousSKUs, CurrentSKUs ) )

View solution in original post

21 REPLIES 21
tamerj1
Super User
Super User
tamerj1
Super User
Super User

@Thigs 

Can you please calrify further: "ideally I'd have some kind of a matching function and let it tell me when it stops matching"

Sure thing, and thanks for the help! 

Ideally, I'd have some kind of function that would look on a specific day, say day 2, and see how many of the SKUs are the exact same as in the previous day (day 1). If more than 90% of the SKUs were a match, it would return something like "match", if less than 90% were a match it would return something like "Change". Then I would calculate on average how many changes happened during a period, say during 90 days.

 

While I know there are matching formulas, I'm not sure how to make one that only looks at the previous day, and I'm not sure how to tell it "hey, if it matches 90%, we're good". 

@Thigs 

It depends. Let's say we're looking at day level, then we can retrieve the VALUES of the SKU's of the current date. 
Suppose the dates are continuous (there are other solutions if not) then the previous date would be the current date - 1. We can use this date to CALCULATE the VALUES of SKU's of the previous date. Then simply we can DIVIDE the COUNTROWS of the INTERSECT between the two VALUES over the COUNTOWS of VALUES of the current date. Would that make sense to you?

Hi! Ok, this looks helpful but I'm still confused. 

 

I created a summary table with the date and SKU of each. Now, for this formula, do I need to make a column so it iterates, or a measure?

 

To me, it seems like I'd do - 

Match Percent = CALCULATE(VALUES('SKU Distribution Table'[SKUs]),'SKU Distribution Table'[Date Only] = DATEADD('SKU Distribution Table'[Date Only] -1)

Or something like that to get the values of the date prior. 

@Thigs 

I hope by summary table you mean table visual. Then you can create a measure. To retrieve the table of previous SKU's you need to use CALCULATETABLE.

DATEADD might not work being time intelligence function therefore you can use

CALCULATETABLE(VALUES('SKU Distribution Table'[SKUs]),'SKU Distribution Table'[Date Only] = MAX('SKU Distribution Table'[Date Only]) -1)

I'm getting this error - 

 

PBI Error.PNG

Here is a screenshot of my table - 

PBI Table.PNG

 

 

@Thigs

Sorry I got distracted by something else. 

What is the code you have used. Can you please share? It is a measure orca calculated column?

No worries, thank you SO much for your help!

 

Matching Percent = CALCULATETABLE(VALUES('SKU Distributions'[SKU]),'SKU Distributions'[Date Only] = MAX('SKU Distributions'[Date Only]) -1)

SKU is simply a list of SKUs. Date Only is a list of dates (with the time stamp removed). Should it be a calculated column? I figured it was a measure since each row in the table is not one date - each row is a date + a sku. 

@Thigs 

This is only part of the complete measure

Matching Percent =
VAR CurrentSKUs =
    VALUES ( 'SKU Distributions'[SKU] )
VAR PreviousSKUs =
    CALCULATETABLE (
        VALUES ( 'SKU Distributions'[SKU] ),
        'SKU Distributions'[Date Only]
            = MAX ( 'SKU Distributions'[Date Only] ) - 1
    )
RETURN
    COUNTROWS ( INTERSECT ( PreviousSKUs, CurrentSKUs ) )

Ok, so if I'm reading this correctly, this gives me the number of SKUs that are the same as the previous day. Then I need a percent, so I would divide by PreviousSKUs? Or do I need a new variable?

Yes no need for new measure 

I tried this this morning - it is back to giving me the error about not expecting multiple values. Here's what I changed the measure to (old one was working perfectly)

 

Matching Percent =
VAR CurrentSKUs =
VALUES ( 'SKU Distributions'[SKU] )
VAR PreviousSKUs =
CALCULATETABLE (
VALUES ( 'SKU Distributions'[SKU] ),
'SKU Distributions'[Date Only]
= MAX ( 'SKU Distributions'[Date Only] ) - 1
)

VAR NumRows = COUNTROWS ( INTERSECT ( PreviousSKUs, CurrentSKUs ) )
RETURN
DIVIDE(NumRows, PreviousSKUs)

You missed the COUNTROWS of "PreviousSKUs 

Like this?

Matching Percent 2 =
VAR CurrentSKUs =
VALUES ( 'SKU Distributions'[SKU] )
VAR PreviousSKUs =
CALCULATETABLE (
VALUES ( 'SKU Distributions'[SKU] ),
'SKU Distributions'[Date Only]
= MAX ( 'SKU Distributions'[Date Only] ) - 1
)

VAR NumRows = COUNTROWS ( INTERSECT ( PreviousSKUs, CurrentSKUs ) )
RETURN
DIVIDE(NumRows, COUNTROWS(PreviousSKUs))
 
It just returns "1" for everything....

Can you share a screenshot?

@Thigs 

You have added a column. Go back to the query editor and send some screenshots. It should not a problem to fix it. 

SKU Count is just a count of SKUs - at first I thought that was what you meant by values. 

Power Query Clip.PNG

 

Please filter out null

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.