Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lt79_Pax
Helper II
Helper II

Optimizing DAX using IF vs DIVIDE section error

Dear Power BI Representative,
I am reviewing the Choosing between IF and DIVIDE section of the 'Definitive Guide to DAX' Chapter 20.
When I try to run the DAX expression I receive an error message regarding the Sales table.
I do not understand why this query is not functioning. Please advise.

Thank you.

DEFINE
MEASURE Sales[Average Price (slow)] =
VAR Quantity = SUM ( Sales[Quantity] )
VAR SalesAmount = [Sales Amount]
VAR Result =
IF (
Quantity <> 0,
SalesAmount / Quantity
)
RETURN result
EVALUATE
TOPN (
502,
SUMMARIZECOLUMNS (
ROLLUPADDISSUBTOTAL(
ROLLUPGROUP(
Customer[CustomerKey],
'Product[Brand]
), "IsGrandTotalRowTotal"
),
"Average_Price_slow_",'Sales'[Average Price (slow)]
),
[IsGrandTotalRowTotal], 0,
'Customer'[CustomerKey], 1,
'Product'[Brand], 1
)
ORDER BY
[IsGrandTotalRowTotal] DESC,
'Customer'[CustomerKey],
'Product'[Brand]

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

 Hi, @lt79_Pax 

 

A single quotation mark(‘)should be added after the product table name.

ROLLUPGROUP ( Customer[CustomerKey], 'Product'[Brand] )

v-angzheng-msft_0-1619755695025.jpeg

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-angzheng-msft
Community Support
Community Support

 Hi, @lt79_Pax 

 

A single quotation mark(‘)should be added after the product table name.

ROLLUPGROUP ( Customer[CustomerKey], 'Product'[Brand] )

v-angzheng-msft_0-1619755695025.jpeg

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.