Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 ReportingThe Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!