Forum Discussion
carolinastalo
5 years agoFrequent Visitor
Problems with Context in Measures
Hello all I have this data structure: Employee Total Cost Department John $ 1.000 A Phil $ 2.000 A Mary $ 800 B ...
- 5 years ago
Hi, carolinastalo
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
You may create measures as below.
TC = SUM('Table'[Total Cost])SDC = COALESCE( CALCULATE( SUM('Table'[Total Cost]), FILTER( 'Table', 'Table'[Department] in {"B","D"} ) ),0 )N-SDC = COALESCE( CALCULATE( SUM('Table'[Total Cost]), FILTER( 'Table', 'Table'[Department] in {"A","C"} ) ),0 )Ratio = DIVIDE( COALESCE( CALCULATE( SUM('Table'[Total Cost]), FILTER( ALL('Table'), 'Table'[Department] in {"B","D"} ) ),0 ), COALESCE( CALCULATE( SUM('Table'[Total Cost]), FILTER( ALL('Table'), 'Table'[Department] in {"A","C"} ) ),0 ) )Cost With Ratio = [N-SDC]*(1+[Ratio])Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
veenashenolikar
5 years agoHelper V
Hi carolinastalo ,
Change your ratio measure as below:
Ratio% = CALCULATE(SUM(Table_Name[SDC])/SUM(Table_Name[N-SDC]),ALL(Sheet2))
Use % as data type here
And then update Cost with ratio measure as below:
Cost _ratio = sum(Sheet2[N-SDC]) * (1+[Ratio%])
If I helped resolve your issue please mark this as a solution
Regards,
Veena Shenolikar