Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I am trying to create a Gross Margin Mix- for this I would use the following calculations
GrossMargin(per Row) / The Sum of all comparable Gross margins
I have a column with Gross Margin and a Column stating whether the item is comparable (Yes/No)
The formula can either be based on CY or PY.
Thank you
Solved! Go to Solution.
You should do this in Power BI with DAX, not Power Query. It will not perform well in Power Query as it isn't designed to dynamically filter tables. See below.
Some Measure =
VAR varComparable = SELECTEDVALUE('Table'[Comparable])
VAR varNumerator = SUM('Table'[Gross Margin CY])
VAR varDenominator =
CALCULATE(
SUM('Table'[Gross Margin PY]),
'Table'[Comparable] = varComparable
)
RETURN
DIVIDE(varNumerator, varDenominator, BLANK())
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingYou should do this in Power BI with DAX, not Power Query. It will not perform well in Power Query as it isn't designed to dynamically filter tables. See below.
Some Measure =
VAR varComparable = SELECTEDVALUE('Table'[Comparable])
VAR varNumerator = SUM('Table'[Gross Margin CY])
VAR varDenominator =
CALCULATE(
SUM('Table'[Gross Margin PY]),
'Table'[Comparable] = varComparable
)
RETURN
DIVIDE(varNumerator, varDenominator, BLANK())
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting| User | Count |
|---|---|
| 11 | |
| 8 | |
| 7 | |
| 5 | |
| 5 |