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.
Hello,
Thanks for reading.
I am trying to create a measure utilizing SUMX. I want to calculate at the row level a Ratio * Dollar amount and sum it up.
The data is in a similar format as to what is below but due to company policy I dont believe I can post real data.
Date | Product | Sold | Total Dollars Sold |
201901 | A | 10 | 1000 |
201901 | B | 16 | 1200 |
202001 | A | 12 | 1400 |
202001 | B | 16 | 1200 |
The final measure is something like
FinalMeasure = SUMX(SalesTable, [PriceChange] * [Total Dollars Sold])
I created a price measure--
Price = DIVIDE(SUM(Total Dollars Sold), SUM(Sold))
Then creating a Prior Year Price--
PYPRICE = CALCULATE([Price], SAMEPERIODLASTYEAR('YearMonthBridge'[Date]))
Then a Price Change measure by taking the quotient of the above two measures.
While troubleshooting my SUMX measure i began to SUMX each portion of the measure to determine where the issue was. When I did a SUMX of the PY measure--
SUMXPY = SUMX(SalesTable,PYPRICE)
The returned value is always nothing/null. All of the other SUMX(PRICE) etc... are working correctly.
Edit-- I should also add. The PY Price measure works correctly by itself as my Date column is connected to a Date Table.
Is it possible to use SUMX with Time Intelligence? I am having a hard time wrapping my head around this!! Any help would be appreciated.
Thanks for reading
Solved! Go to Solution.
Solved with this answer! Thanks all!
Solved with this answer! Thanks all!
@Anonymous , Not very clear. But you should use a date table for time intelligence
example
PYPRICE = CALCULATE([Price], SAMEPERIODLASTYEAR('Date'[Date]))
PYPRICE = CALCULATE([Price], dateadd('Date'[Date],-1,year))
Refer to my video on why time intelligence can fail
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA
@Anonymous seems like you are making it super complicated. What is your end goal?
Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k Apologies, I believe I solved it this morning so I should be able to encapsulate the problem.
This measure below returns null:
PriceChange = SUMX(Sales Table, Divide([Price], CALCULATE([Price], SAMEPERIODLASTYEAR(YearMonthBridge[Date]))))
@parry2k I apologize for the confusion-- please see below-
PriceChange =
Var Pricechange = Divide([Price], CALCULATE([Price], SAMEPERIODLASTYEAR(YearMonthBridge[Date])))
return SUMX(Sales Table, Pricechange)
Is producing the wrong results.
Should the below measure work or produce Null? Now that I think about it the data from the SAMEPERIODLASTYEAR() is not on the same row as current year? Would the solution be to create a column with prior year data on current year rows?
PriceChange = SUMX(Sales Table, Divide([Price], CALCULATE([Price], SAMEPERIODLASTYEAR(YearMonthBridge[Date]))))
If this is still confusing maybe I can create a sample .pbix with fake data
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |