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
perner123
Regular Visitor

Get Previous column value

I am very new to PBI Desktop and currently fighting something which should be quite simple.

PBI.png

PBI2.png


I tried to calculate a new measure "PrevValue" which should include the "Value" of the previous month.
The DAX expressions i tried:

  1. PrevValue = CALCULATE(SUM(PERST[Value]);PARALLELPERIOD('INV V_DIM_DATE'[FULLDATE].[Date];-1;MONTH))
    returns the Value of the same Period
  2. PrevValue = CALCULATE(SUM(PERST[Value]);PREVIOUSMONTH('INV V_DIM_DATE'[FULLDATE].[Date]))
    returns an empty value

Ideally it should always show the difference between the value of the current & previous period, even if the user doesn't select all periods in a row.

I have no clue, why even showing the previous value doesn't work. Is there any simple thing I am missing?


So the result should look like this (PrevValue 0 in first period, as no previous period available)
prev.png

 

thanks in advance

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@perner123 few things:

 

- make your INV V_DIM_DATE as date table

- remove .[date] from your measures.



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.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

Check this

https://community.powerbi.com/t5/Desktop/DAX-getting-previous-value/td-p/489921

 

But if need this year vs last year. try these formula

Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),('Date'[Date Filer])))
Last Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),dateadd('Date'[Date Filer].-12,month)))


Year  = CALCULATE(SUM(table[column]),DATESYTD(endofmonth(dateadd('Date'[Date Filer],-1,MONTH))))
Last Year  = CALCULATE(SUM(table[column]),DATESYTD(endofmonth(dateadd('Date'[Date Filer],-13,MONTH))))


Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),endofmonth(dateadd('Date'[Date Filer].-1,month))))
Last Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),endofmonth(dateadd('Date'[Date Filer].-13,month))))

 

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

parry2k
Super User
Super User

@perner123 few things:

 

- make your INV V_DIM_DATE as date table

- remove .[date] from your measures.



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.

Thanks a lot! After changing both things you mentioned, it works fine!
Initially i struggeled creating the table as date table, as there was a "dummy-element" included and i received the message "date table cannot have gaps". So i just excluded this element and everything worked fine.

@perner123 here is a post on how to mark you table as date table.



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.

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.