cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Difference from Previous Column/Date

Hello All!

I am looking for a simple calculation in power bi that I can't seem to figure out. I am looking to get the difference from previous date. I'm not quite sure how to get this to work. I have included a picture of what I would like the end result to be in power bi.  I would like to  calculate the difference from the previous date and dynamically show every 2 days (i.e data for the 4/1/20, 4/3/20, 4/5/20 and so on). I did create a date table and created a relationship to my date column in my data table, but still haven't gotten anything to work.

 

Any help is appreciated!

 

Thank you in advance!

 

 

excel test file.png

3 REPLIES 3
Highlighted
Super User IX
Super User IX

Re: Difference from Previous Column/Date

@Slimage - Please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Frequent Visitor

Re: Difference from Previous Column/Date

HI @Slimage ,

If I understand your question correctly, You need different with the value from a day -2.

Here I have replicated the scenario. Let me know if it works for you or not.

 

Data:

ashish_dakhare_0-1594134329479.pngashish_dakhare_1-1594134399103.png

Value D = SUM('Table'[Value])
VAlue D-2 = CALCULATE(SUM('Table'[Value]),DATEADD('Table'[Date],-2,DAY))
Diff = IF(ISBLANK([VAlue D-2]), BLANK(),[Value D]-[VAlue D-2])
 
Highlighted
Super User IX
Super User IX

Re: Difference from Previous Column/Date

@Slimage , refer if these measures can help

example

Last Day Non Continous = CALCULATE(sum('order'[Qty]),filter(all('Date'),'Date'[Date] =MAXX(FILTER(all('Date'),'Date'[Date]<max('Date'[Date])),Table['Date'])))
Day behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))
Diff COlumn = datediff(maxx(filter(Table,Table[Date]<earlier(Table[Date]) && Table[Numberf]= earlier(Table[Numberf])  ),Table[Date]) ,Table[Date],Day)

This Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...


Appreciate your Kudos.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Upcoming Events

Community Summit North America – Join Online!

Join this community-driven Power Platform digital event for unbiased support and problem-solving.

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Top Solution Authors