Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Changing the date when comparing values

Hi,

I'm doing some calculations where I calculate the values +1 day and +8 days against the selected date. But when I'm selecting a date in first table the date doesn't change in the other tables. I tried using it with a date table and also creating extra columns in my Table1 but nothing seems to work. Can someone help me and tell me if it is even possible?

 

#1

Annotation 2020-01-30 150011.png

 

 

#2

Annotation 2020-01-30 150038.png

When selected the expected date should be: 

demand vs supply = Selected date (ex. 12/06/2019)

+1 day = Selected date +1 (ex. 12/07/2019)

+8 day = Selected date +8 (ex. 12/14/2019)

 

Annotation 2020-01-30 150038 - Copy.png

 

Relationships

 

I'm not using any, everything is data from the same view. I can use a date table and for the the relationship would be:

date | one to Many (1:*) |  table

 

Data

The data is saved in a pivoted table where the column names are in 'attribute_name' and the values from the table are in 'value'. 

Annotation 2020-01-30 152156.png

 

 

Measure's

I'm using 2 measures to calculate the difference for the +1 Day and 2 measures to calculate +8 Days. Below is the one for +1 Day.

 

Measure 1 - getting the value for +1 day


#1_Selecting_+1Day = VAR PriorDay = SELECTEDVALUE(table1[date])+1

RETURN
CALCULATE(
( SUM(table1[Value])),
ALL ( table1[date]),
table1[date] = PriorDay
)

 

Measure 2 - getting the difference for the two days. 

 

#2_Subtraction_from_prev_day = [#1_Selecting_+1Day] - SUM(table1[Value])

 

 

I hope someone can help me, if you need more information please let me know. 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need measures as below:

For +1 day:

 

+1day = SELECTEDVALUE('Table'[Date])+1
+1 value = SELECTEDVALUE('Table'[Value])+1

 

For +8 days:

 

+8 day = SELECTEDVALUE('Table'[Date])+8
+8 value = SELECTEDVALUE('Table'[Value])+8

 

Finally ,you will see:

 

Annotation 2020-01-31 150359.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly

View solution in original post

7 REPLIES 7
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need measures as below:

For +1 day:

 

+1day = SELECTEDVALUE('Table'[Date])+1
+1 value = SELECTEDVALUE('Table'[Value])+1

 

For +8 days:

 

+8 day = SELECTEDVALUE('Table'[Date])+8
+8 value = SELECTEDVALUE('Table'[Value])+8

 

Finally ,you will see:

 

Annotation 2020-01-31 150359.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly

Anonymous
Not applicable

The first formula is exactly what I need. But I can't put that measure as my rows in my matrix table. There is a work around for putting a measure in, so i'm going to try that.

amitchandak
Super User
Super User

In case you need for comparison, First, create a calendar table and mark it as Date. Join it with the date of your table

One Day behind =Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Day))

8Day behind =Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-8,Day))

One Day ahead =Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],1,Day))

 

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/

 

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 -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I created the calendar table and joined it with my table. The comparing is going good but my dates are still staying the same. 

Please provide a sample what you want to show vs what you are getting

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I updated the post with a foto of the expected result I'm trying to get.

Not sure I still got it.

But if we want to show date of 7th and show diff 6th and 7th we use -1 day measure

but If want show same on 6th we will use +1 day measure

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.