Forum Discussion
Power BI - Scalar error
Hello,
I am trying to write a DAX query to get the sales contribution by region for the last 90 days and am getting the following error - The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
How can I fix this? The code I wrote is below:
- Anonymous2 years ago
lbendlin Thanks for your contribution on this thread.
Hi gbarr12345 ,
According to your sample data, the order data are on year 2015. Then the condition ( Orders[Order Date] >= TODAY() - 90 && Orders[Order Date] <= TODAY() ) will not return any data, that's why the measure return the blank value...
Best Regards
5 Replies
- lbendlinSuper User
TOPN returns a table, even if it is TOPN,1.
Return MAXX or CONCATENATEX
Sales Contribution by region =VAR StartDate = TODAY() - 90VAR EndDate = TODAY()RETURNMAXX(TOPN(1,SUMMARIZE(FILTER(Orders , Orders[Order Date] >= StartDate && Orders[Order Date] <= EndDate),Orders[Region],"TotalSales" , SUM(Orders[Sales])),[Total Sales] , DESC),[Region]) - gbarr12345Post Prodigy
Thanks for that. The error went away but now no data is appearing when I try to put it into a table visualisation:
I am using a sample superstore data set to test this dax formula.
The data I'm using is below:
Order Date Ship Date Profit Quantity ordered new Sales 13/06/2015 15/06/2015 4390.3665 12 6362.85 15/06/2015 17/06/2015 -84.4376 13 58.68 15/06/2015 16/06/2015 24.312 18 53.1 12/06/2015 14/06/2015 349.4091 17 506.39 3/06/2015 8/06/2015 1892.424 19 3127.69 7/06/2015 9/06/2015 22.818 16 216.04 22/06/2015 24/06/2015 -16.2 16 303.59 22/06/2015 24/06/2015 -20.25 65 1233.32 22/06/2015 23/06/2015 -3.381 17 47.31 22/06/2015 23/06/2015 -2.7048 4 11.13 2/06/2015 3/06/2015 91.956 13 312.59 2/06/2015 3/06/2015 -2.544 6 64.4 18/06/2015 22/06/2015 360.24 21 772.56 2/06/2015 2/06/2015 -21.48775 4 27.3 2/06/2015 2/06/2015 44.6775 3 64.75 - AnonymousNot applicable
lbendlin Thanks for your contribution on this thread.
Hi gbarr12345 ,
According to your sample data, the order data are on year 2015. Then the condition ( Orders[Order Date] >= TODAY() - 90 && Orders[Order Date] <= TODAY() ) will not return any data, that's why the measure return the blank value...
Best Regards
- gbarr12345Post Prodigy
Ah yes I understand. Apologies I should have spotted that.
Thank you for your response.
Is there a good alternative code instead of TODAY() - 90 to get 90 days before that date in 2015?
Many Thanks.