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

Calculate data based on yesterday's figures or weekly figures.

Hi,

 

I have this table of data:

vicgonsam_0-1620920783868.png

 

The row dates are reservation dates for a hotel, and the colum shows when those reservations will stay in the future.

 

I need to calculate how many reservations were made yesterday, during the last 7 days and last 14 days.

 

I tried to use

 

CALCULATE ( [Roomnights], DATEADD(Reservation dates[date], -1,DAY))

 

but it doesn't work, it gives me a weird number that doesn't make any sense (2,783).

 

So results for this example should be:

Pu1 (sum of reservations made yesterday) = 43

Pu7 (sum of reservations made in the last 7 days) = 1,686  

Pu14 (sum of reservations made in the last 14 days) = 2,708 (as the example only has 12 days)

 

What am I doing wrong? 

 

Thanks for your help! 

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Could you please share some sample data in table RoomnightsReservation dates (exclude sensitive data)? Is there any relationship created between these two tables? Did you create date dimension table?

On the other hand, you can refer the content in the following links to get it.

DAX – PREVIOUSDAY Function

Calculate Transactions In Last N Days in Power BI Using DAX

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

By the way, using PREVIOUSDAY function doesn't provide the right figure either:

 

CALCULATE(Roomnights[Roomnights], PREVIOUSDAY('Reservation dates'[Date])) gives me 118 instead of 43 

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.