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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Get sum of previous date when there are gaps in date column (Measure)

So I've been stuggling with this, seems like quite a simple concept but that does seem to happen a lot with PBI

 

Here's some example data to paint a picture:

 

Client   Date   Sale
A   11/09/2021   100
B   11/09/2021   250
A   13/09/2021   300
B   14/09/2021   250

 

There's a date filter on the page I'm trying to get this measure working on filtered to 13/09/2021. I'm trying to create a card visualisation displaying a sum of the sales on the previous date in the table based on this filter (so sum should be 350).

 

PREVIOUSDAY doesn't work here, it only works when I set the filter to 14/09/2021. So I need a more dynamic solution for days when there are no sales in the database.

 

Any help would be greatly appreciated. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

Get the previous date first

Vera_33_0-1637283213978.png

preDaySale = 
VAR CurDay = SELECTEDVALUE(yourTable[Date])
VAR PreDay = MAXX(FILTER(ALL(yourTable),yourTable[Date]<CurDay),yourTable[Date])
RETURN
SUMX(FILTER(ALL(yourTable),yourTable[Date]=PreDay),yourTable[Sale])

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

 

Get the previous date first

Vera_33_0-1637283213978.png

preDaySale = 
VAR CurDay = SELECTEDVALUE(yourTable[Date])
VAR PreDay = MAXX(FILTER(ALL(yourTable),yourTable[Date]<CurDay),yourTable[Date])
RETURN
SUMX(FILTER(ALL(yourTable),yourTable[Date]=PreDay),yourTable[Sale])

 

Anonymous
Not applicable

This worked, thank you very much! I hope others find this solution too as I spent a long time searching the forum to no avail.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.