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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
babyjb1979
Helper I
Helper I

Fill up gaps with duplicate date

Hi Power Bi Gurus,

 

I have a table with date and value, I am using the DAX code to fill up the gaps as following:

New Value =
VAR LastNonBlankDate =
    CALCULATE (
        FIRSTNONBLANK ( TableName[Date], 1 ),
        FILTER (
            ALL ( TableName ),
            TableName[Date] >= EARLIER ( TableName[Date] )
            &&TableName[ID] = EARLIER ( TableName[ID] )
                && FIRSTNONBLANK( TableName[Value],1 ) )   )
   RETURN
    CALCULATE (
        MIN( TableName[Value] ),
        FILTER ( ALL ( TableName ), TableName[Date] = LastNonBlankDate )  )

babyjb1979_0-1696604104804.png

It is perfectly solution. But if there are duplicated date, and value(01/02/2023 which is duplicated) something wrong happened. I have to keep the duplicated rows. 

babyjb1979_2-1696604403808.png

So I want to introduce a var to summarize the date and value, then I stuck here :

New Value 2 =
VAR tb=SUMMARIZE('TableName',TableName[ID],TableName[Date],TableName[Value])
VAR LastNonBlankDate=

    CALCULATE (
        FIRSTNONBLANK ( [Date], 1 ),
        FILTER (
            ALL ( tb ),
            [Date] >= EARLIER ( [Date] )
            &&[ID] = EARLIER ( [ID] )
                && not( ISBLANK([Value]) )
        ))
   
RETURN
    CALCULATE (
        SUM( [Value] ),
        FILTER ( ALL ( tb ), [Date] = LastNonBlankDate )
    )

Please help me out!!!

 

Thank you in advance!

Branko

 

IDDateValue
A1/1/2023 
A1/2/20236
A1/2/20236
A1/4/2023 
A1/5/202312
A1/6/2023 
B1/3/2023 
B1/6/2023 
B1/7/2023 
B1/8/2023 
B1/9/20238
B1/10/2023 
B1/15/2023 
B1/17/202343
B1/18/2023 
C1/19/2023 
C1/20/2023 
C1/21/202311
C1/22/2023 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @babyjb1979 ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
IF(
    MAX('Table'[Value]) =BLANK(),
    MINX(
        FILTER(ALL('Table'),
        'Table'[ID]=MAX('Table'[ID])&&'Table'[Date]>MAX('Table'[Date])&&'Table'[Value]<>BLANK()),[Value]),
        MAX('Table'[Value]))

2. Result:

vyangliumsft_0-1696911430339.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
babyjb1979
Helper I
Helper I

@Anonymous 
Hi Liu,

The logic appears to be correct, but please check that the data is still incorrect. Please use new data to test

babyjb1979_0-1696976486893.png

IDDateValue
10232019/1/2023 
10232019/2/2023 
10232019/3/2023 
10232019/4/2023 
10232019/5/2023 
10232019/6/2023 
10232019/7/2023 
10232019/8/2023 
10232019/9/2023 
10232019/10/2023 
10232019/11/2023 
10232019/12/202312
10232019/26/2023 
10232019/27/2023 
10232019/28/2023 
10232019/29/2023 
10232019/30/2023 
102320110/1/2023 
102320110/2/20237
2219349/1/2023 
2219349/2/2023 
2219349/3/2023 
2219349/4/2023 
2219349/5/20235
2219349/11/2023 
2219349/12/2023 
2219349/13/2023 
2219349/14/2023 
2219349/15/2023 
2219349/16/2023 
2219349/17/2023 
2219349/18/2023 
2219349/19/2023 
2219349/20/2023 
2219349/21/2023 
2219349/22/2023 
2219349/23/2023 
2219349/24/2023 
2219349/25/2023 
2219349/26/202316
2460759/1/2023 
2460759/2/2023 
2460759/3/2023 
2460759/4/2023 
2460759/5/2023 
2460759/6/2023 
2460759/7/2023 
2460759/8/2023 
2460759/9/2023 
2460759/10/2023 
2460759/11/2023 
2460759/12/2023 
2460759/13/2023 
2460759/14/202314
2460759/27/2023 
2460759/28/2023 
2460759/29/2023 
2460759/30/2023 
24607510/1/2023 
24607510/2/2023 
24607510/3/20237
Anonymous
Not applicable

Hi  @babyjb1979 ,

 

Here are the steps you can follow:

1. Create measure.

Measure =
IF(
    MAX('Table'[Value]) =BLANK(),
    MINX(
        FILTER(ALL('Table'),
        'Table'[ID]=MAX('Table'[ID])&&'Table'[Date]>MAX('Table'[Date])&&'Table'[Value]<>BLANK()),[Value]),
        MAX('Table'[Value]))

2. Result:

vyangliumsft_0-1696911430339.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

@Anonymous 
The logic appears to be correct, but please check that the data is still incorrect. Please use the new data to test. Thank you very much for your time and help!!!

babyjb1979_0-1696975960646.png

 

 

  
   
IDDateValue
10232019/1/2023 0:00 
10232019/2/2023 0:00 
10232019/3/2023 0:00 
10232019/4/2023 0:00 
10232019/5/2023 0:00 
10232019/6/2023 0:00 
10232019/7/2023 0:00 
10232019/8/2023 0:00 
10232019/9/2023 0:00 
10232019/10/2023 0:00 
10232019/11/2023 0:00 
10232019/12/2023 0:0012
10232019/26/2023 0:00 
10232019/27/2023 0:00 
10232019/28/2023 0:00 
10232019/29/2023 0:00 
10232019/30/2023 0:00 
102320110/1/2023 0:00 
102320110/2/2023 0:007
2219349/1/2023 0:00 
2219349/2/2023 0:00 
2219349/3/2023 0:00 
2219349/4/2023 0:00 
2219349/5/2023 0:005
2219349/11/2023 0:00 
2219349/12/2023 0:00 
2219349/13/2023 0:00 
2219349/14/2023 0:00 
2219349/15/2023 0:00 
2219349/16/2023 0:00 
2219349/17/2023 0:00 
2219349/18/2023 0:00 
2219349/19/2023 0:00 
2219349/20/2023 0:00 
2219349/21/2023 0:00 
2219349/22/2023 0:00 
2219349/23/2023 0:00 
2219349/24/2023 0:00 
2219349/25/2023 0:00 
2219349/26/2023 0:0016
2460759/1/2023 0:00 
2460759/2/2023 0:00 
2460759/3/2023 0:00 
2460759/4/2023 0:00 
2460759/5/2023 0:00 
2460759/6/2023 0:00 
2460759/7/2023 0:00 
2460759/8/2023 0:00 
2460759/9/2023 0:00 
2460759/10/2023 0:00 
2460759/11/2023 0:00 
2460759/12/2023 0:00 
2460759/13/2023 0:00 
2460759/14/2023 0:0014
2460759/27/2023 0:00 
2460759/28/2023 0:00 
2460759/29/2023 0:00 
2460759/30/2023 0:00 
24607510/1/2023 0:00 
24607510/2/2023 0:00 
24607510/3/2023 0:007

 

_elbpower
Resolver III
Resolver III

Would you like to address gaps in your data by inserting missing dates and updating the value column with the most recent non-blank value? For instance, if there's a missing date like 1/3/2023, would you want to create a new row with that date and a value of 6 copied from the previous date?

I want to fill up the blank with the lastest non-blank value

babyjb1979_0-1696611654091.png

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.