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
Anonymous
Not applicable

Change in Number of Days

Hi

I'm trying to wrap my head around how to perform the following. All date formats are YYYY-MM-DD

 

I've the table below which consists of the following columns:

EXISTING COLUMNS

Serial: Serial Number of an item

Arrival to WH: The date where the material is expected to arrive to the warehouse.

FileDate: I get updates in XLSX file. So I extract the file date to record when the update arrived. The updates does not arrive every day and hence you can see gap in dates.

 

CALCULATED COLUMNS TO BE CREATED

PreviousFileDate: This is date of the file that is prior to the file in each row. e.g. row # 4, the file date in this row is 2022-09-02, the PreviousFileDate is 2022-08-31 and NOT 2022-08-01.

 

DaysDifferenceFromPreviousDate: This is difference in days between two consequitive ArrivalToWH.

ArrivalToWH in Row 2 - ArrivalToWH in Row 1

ArrivalToWH in Row 3 - ArrivalToWH in Row 2

....etc

ChangeFromLastFileDate: This is difference in days between the ArrivalToWH in the latest file/update and the ArrivalToWH in each row.

 

ArrivalToWH in Row 7 - ArrivalToWH in Row 6 ==> DateDiff (ArrivalToWH in Row 6, ArrivalToWH in Row 7)

ArrivalToWH in Row 7 - ArrivalToWH in Row 5 ==> DateDiff (ArrivalToWH in Row 5, ArrivalToWH in Row 7)

ArrivalToWH in Row 7 - ArrivalToWH in Row 4 ==> DateDiff (ArrivalToWH in Row 4, ArrivalToWH in Row 7)

ArrivalToWH in Row 7 - ArrivalToWH in Row 3

....etc

 

SerialArrival ToWH FileDatePreviousFileDateChangeFromPreviousDateChangeFromLastFileDate
102851932022-09-092022-08-29  0
102851932022-09-092022-08-302022-08-2900
102851932022-09-092022-08-312022-08-3000
102851932022-09-092022-09-022022-08-3100
102851932022-11-022022-09-042022-09-02-77
102851932022-11-102022-09-062022-09-048-1
102851932022-11-092022-09-112022-09-06-1 

 

 

Thanks in advance

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a column by dax.

Column =
CALCULATE (
    MAX ( 'Table'[FileDate] ),
    FILTER (
        ALL ( 'Table' ),
        [FileDate] < EARLIER ( 'Table'[FileDate] )
            && [Serial Number] = MAX ( 'Table'[Serial Number] )
    )
)

Or create a measure by dax

Measure = CALCULATE(MAX('Table'[FileDate]),FILTER(ALL('Table'),[Serial Number]=MAX('Table'[Serial Number])&&[FileDate]<MAX('Table'[FileDate])))

the final show:

vyalanwumsft_0-1663551939229.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks, but I'm not sure what are you returning with the new column?

Hi, 

@Anonymous ;

Maybe I understand the error, can you tell me with an example the result and logic you want to output?


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Power BI has no concept of row numbers. You need to indicate the order that your data should be processed in. Is FileDate guaranteed to be unique?

Anonymous
Not applicable

Hi @lbendlin  for each Serial Number, there is one update on each day. You can not find two updates for the same serial number in each filedate.

Below is example:

Serial NumberFileDate
102851932022-08-29
102859812022-08-29
102857762022-08-29
102851932022-08-30
102859812022-08-30
102857762022-08-30
102851932022-09-01
102859812022-09-01

 

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