Forum Discussion
SKU Distribution Trend?
- 4 years ago
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 ) )
I'm getting this error -
Here is a screenshot of my table -
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?
- Thigs4 years agoHelper IV
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?
- Thigs4 years agoHelper IV
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. - tamerj14 years agoCommunity Champion
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 ) ) - tamerj14 years agoCommunity Champion
Yes no need for new measure
- Thigs4 years agoHelper IV
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 ) )RETURNDIVIDE(NumRows, PreviousSKUs) - tamerj14 years agoCommunity Champion
You missed the COUNTROWS of "PreviousSKUs
- Thigs4 years agoHelper IV
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 ) )RETURNDIVIDE(NumRows, COUNTROWS(PreviousSKUs))It just returns "1" for everything.... - tamerj14 years agoCommunity Champion
Can you share a screenshot?