Forum Discussion
Weighted average without blanks
- 4 years ago
Hi lennardheyder,
You can use calculatetable() to adjust the VAR __CATEGORY_VALUES
VAR __CATEGORY_VALUES= CALCULATETABLE(VALUES('MatHier'[Article name]), ALLNOBLANKROW('MatHier'[minimum prices]))
If does not work, please try this code or share your pbix file without sensitive data.
or try this code:
Weighted Pricing Delta = VAR _s = SUMMARIZE ( 'MatHier', [Article name], "avg", AVERAGE ( 'PREISBAND'[Δ Pricing letter[CUR / UOW]]] ), "sum", SUM ( 'OH01 + OS01'[NES 3rd party (€)] ) ) VAR _1 = SUMX ( FILTER ( _s, [avg] <> BLANK () ), [avg] * [sum] ) VAR _2 = SUMX ( FILTER ( _s, [avg] <> BLANK () ), [sum] ) RETURN DIVIDE ( _1, _2 )Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi lennardheyder,
You can use calculatetable() to adjust the VAR __CATEGORY_VALUES
VAR __CATEGORY_VALUES= CALCULATETABLE(VALUES('MatHier'[Article name]), ALLNOBLANKROW('MatHier'[minimum prices]))
If does not work, please try this code or share your pbix file without sensitive data.
or try this code:
Weighted Pricing Delta =
VAR _s =
SUMMARIZE (
'MatHier',
[Article name],
"avg", AVERAGE ( 'PREISBAND'[Δ Pricing letter[CUR / UOW]]] ),
"sum", SUM ( 'OH01 + OS01'[NES 3rd party (€)] )
)
VAR _1 =
SUMX ( FILTER ( _s, [avg] <> BLANK () ), [avg] * [sum] )
VAR _2 =
SUMX ( FILTER ( _s, [avg] <> BLANK () ), [sum] )
RETURN
DIVIDE ( _1, _2 )
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.