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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to summarize the values from the previous available date?

Hello

 

I was trying to summarize a field, grouping it by the day before according to the most current date (D-1), the problem is that I noticed the dataset not always has the data from a previous day (sometimes is D-2 or D-5, etc.), So I need a Measure capable to detect the data from the max date previous the current date, here is my try, it just Summarize D-1, could you help me, guys?

 

D-1 = VAR DateFilter =
SELECTCOLUMNS ( VALUES ( Agencies_Inventory[date]), "Date-1", Agencies_Inventory[date]-1)
RETURN
CALCULATE (
SUM(Agencies_Inventory[envase_disponible]),
ALL ( 'Agencies_Inventory' ),
INTERSECT ( ALL ( 'Agencies_Inventory'[date] ), DateFilter )
)

 

 
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

D-1 = 
VAR D = SELECTEDVALUE(Agencies_Inventory[date])
VAR P = CALCULATE(MAX(Agencies_Inventory[date]),ALL ( 'Agencies_Inventory' ),Agencies_Inventory[date]<D)
RETURN CALCULATE (
SUM(Agencies_Inventory[envase_disponible]),
ALL ( 'Agencies_Inventory' ),
,Agencies_Inventory[date]=P
)

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

D-1 = 
VAR D = SELECTEDVALUE(Agencies_Inventory[date])
VAR P = CALCULATE(MAX(Agencies_Inventory[date]),ALL ( 'Agencies_Inventory' ),Agencies_Inventory[date]<D)
RETURN CALCULATE (
SUM(Agencies_Inventory[envase_disponible]),
ALL ( 'Agencies_Inventory' ),
,Agencies_Inventory[date]=P
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors
Users online (597)