Forum Discussion
Average variance by Item
- 1 year ago
Should be a simple two step process.
Create a calculated table of unique ID-Item combinations with their variance
VariancePerIDItem = ADDCOLUMNS ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[Item] ), "Variance", VAR Prices = CALCULATETABLE ( VALUES('Table'[Price]), ALLEXCEPT('Table', 'Table'[ID], 'Table'[Item]) ) RETURN DIVIDE ( MAXX(Prices, [Price]), MINX(Prices, [Price]) ) - 1 )Then, create a measure that calculates the average of non-zero variances per item:
AverageVariancePerItem = AVERAGEX ( FILTER ( VariancePerIDItem, [Variance] <> 0 && VariancePerIDItem[Item] = SELECTEDVALUE('Table'[Item]) ), [Variance] )When you place Item in your visual and use this [AverageVariancePerItem] measure, you’ll get your expected result.
Please mark this post as solution if it helps you. Appreciate Kudos.
Should be a simple two step process.
Create a calculated table of unique ID-Item combinations with their variance
VariancePerIDItem =
ADDCOLUMNS (
SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[Item] ),
"Variance",
VAR Prices =
CALCULATETABLE (
VALUES('Table'[Price]),
ALLEXCEPT('Table', 'Table'[ID], 'Table'[Item])
)
RETURN
DIVIDE ( MAXX(Prices, [Price]), MINX(Prices, [Price]) ) - 1
)
Then, create a measure that calculates the average of non-zero variances per item:
AverageVariancePerItem =
AVERAGEX (
FILTER (
VariancePerIDItem,
[Variance] <> 0
&& VariancePerIDItem[Item] = SELECTEDVALUE('Table'[Item])
),
[Variance]
)When you place Item in your visual and use this [AverageVariancePerItem] measure, you’ll get your expected result.
Please mark this post as solution if it helps you. Appreciate Kudos.