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
Anonymous
Not applicable

SUMX and Time Intelligence

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.

DateProductSoldTotal Dollars Sold
201901A101000
201901B161200
202001A121400
202001B161200

 

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

1 ACCEPTED SOLUTION
Anonymous
Not applicable
5 REPLIES 5
Anonymous
Not applicable
amitchandak
Super User
Super User

@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

https://youtu.be/OBf0rjpp5Hw

https://youtu.be/j0ug-XQgZtg

 

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

parry2k
Super User
Super User

@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.

Anonymous
Not applicable

@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]))))

 

 

 

 

 

 

Anonymous
Not applicable

@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

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.