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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.