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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
cheid_4838
Helper IV
Helper IV

Summarizing data from previous date

I have a database that lists all pick-ups for my business.  I am wanting to create a summarized view of potential pickups within the same state and/or customer that we delivered to the previous day and/or within the same week.  For example we made deliveries to SC on 1/6 and had another pick-up in SC on 1/7 or another day within the week.  I would like to summarize the data as shown below.  I also would like to see those states that did not have another pickup the following day. For example we delivered to NC on 1/7, but no pickups the following day or within the same week.  Any suggestions for how this would work in DAX?  Thanks for your help.

 

OriginStateShipperNameDestStateConsigneeNameShip DateDelivery DateLDMilesMTMilesVol
TNDOMTARSCSOUTHEASTERN PAPERBOARD1/6/251/6/251631631
TNDOMTAR PAPER COMPANYSCSOUTHEASTERN PAPERBOARD1/6/251/6/251631631
GADALTON RECYCLING PLANTTNDOMTAR PAPER COMPANY1/6/251/6/252472471
NCALDI,INCTNDOMTAR PAPER COMPANY1/6/251/6/259763923
NCJC PENNEYTNDOMTAR PAPER COMPANY1/6/251/6/251911911
TNDOMTAR PAPER COMPANYNCPINNACLE CORRUGATED1/7/251/7/25109005
TNDOMTARSCSOUTHEASTERN PAPERBOARD1/7/251/7/2532602
GADALTON RECYCLING PLANTTNDOMTAR PAPER COMPANY1/7/251/7/252472471
SCCANUSA HERSHMAN RECYCLINGTNDOMTAR PAPER COMPANY1/7/251/7/25314682
SCPRATT RECYCLINGTNDOMTAR PAPER COMPANY1/7/251/7/252152151
TNWALMARTTNDOMTAR PAPER COMPANY1/7/251/7/2554541
         
Result     LDMilesMTMilesVol
SC    5292833
TN    1470548
1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@cheid_4838 Create a Calculated Column for Week Number

WeekNumber = WEEKNUM('Table'[Ship Date], 2)

 

Create a Calculated Column for Previous Day

PreviousDay = 'Table'[Ship Date] - 1

 

Measure for LDMiles

dax
TotalLDMiles =
CALCULATE(
SUM('Table'[LDMiles]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

Measure for MTMiles

dax
TotalMTMiles =
CALCULATE(
SUM('Table'[MTMiles]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

Measure for Vol

dax
TotalVol =
CALCULATE(
SUM('Table'[Vol]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

You can create a summarized table to display the results:

dax
SummaryTable =
SUMMARIZE(
'Table',
'Table'[DestState],
"Total LDMiles", [TotalLDMiles],
"Total MTMiles", [TotalMTMiles],
"Total Vol", [TotalVol]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
bhanu_gautam
Super User
Super User

@cheid_4838 Create a Calculated Column for Week Number

WeekNumber = WEEKNUM('Table'[Ship Date], 2)

 

Create a Calculated Column for Previous Day

PreviousDay = 'Table'[Ship Date] - 1

 

Measure for LDMiles

dax
TotalLDMiles =
CALCULATE(
SUM('Table'[LDMiles]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

Measure for MTMiles

dax
TotalMTMiles =
CALCULATE(
SUM('Table'[MTMiles]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

Measure for Vol

dax
TotalVol =
CALCULATE(
SUM('Table'[Vol]),
FILTER(
'Table',
'Table'[DestState] = EARLIER('Table'[DestState]) &&
(
'Table'[Ship Date] = EARLIER('Table'[PreviousDay]) ||
'Table'[WeekNumber] = EARLIER('Table'[WeekNumber])
)
)
)

 

You can create a summarized table to display the results:

dax
SummaryTable =
SUMMARIZE(
'Table',
'Table'[DestState],
"Total LDMiles", [TotalLDMiles],
"Total MTMiles", [TotalMTMiles],
"Total Vol", [TotalVol]
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






I think I figure out the measures noted above.  I was able to get the measures to work when I converted them to a column.  Now the totals I am getting our much higher than they should be.  The table on the left is what I get with the logic noted in the above solution for a one week period.  The table on the right is the result of using the raw data.  I would expect to see that the deststate TN would have a LDMiles total of 4,102 not 283,049.  Is this a result of using a column instead of measures?  Thanks.

 

 

cheid_4838_0-1737036325333.png

 

Anonymous
Not applicable

Hi @cheid_4838,

In fact, measure and calculated column are work on different data levels and you can't use the child level to affect its parent level.
When you use calculated column to replace measure formula, their results will be fixed and not able to respond with filter interaction from slicer/filter.

Notice: the data level of power bi(from parent to child level)

Database(external) -> query table(query, custom function, query parameters) -> data model table(table, calculate column/table) -> data view with virtual tables(measure, visual, filter, slicer)

Regards,

Xiaoxn Sheng

Thanks for the help. Do you know why I am getting this message? I have never seen this before.  

cheid_4838_0-1737033402579.png

 

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