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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Fill blanks with previous value

Hi All,

 

I have the current table below, which as you can see has missing values.

 

CarMonthValue
FiatMar-0810,000
FiatApr-08 
FiatMay-08 
FiatJun-0812,000
FiatJul-08 
FiatAug-08 
AudiMar-0822,000
AudiApr-08 
AudiMay-0824,000
AudiJun-08 
AudiJul-0823,000
AudiAug-08 

 

I need to create a calculated column which fills in those blanks based on the last month for that type of car, so something like this:

 

CarMonthValueValue 2
FiatMar-0810,00010,000
FiatApr-08 10,000
FiatMay-08 10,000
FiatJun-0812,00012,000
FiatJul-08 12,000
FiatAug-08 12,000
AudiMar-0822,00022,000
AudiApr-08 22,000
AudiMay-0824,00024,000
AudiJun-08 24,000
AudiJul-0823,00023,000
AudiAug-08 23,000

 

Does anyone have any ideas how to do this? The issue of offsetting is where there are more than two blank rows in sequence.

 

Thanks,

 

Jack

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

what do you mean by 'outside of Power Query'? is it calculated table?
in DAX you can try this, it works as long as Month column has type date

Value2 =
VAR CurrentCar = 'Table'[Car]
VAR CurrentDate = 'Table'[Month]
VAR LastDateWithValue =
    CALCULATE (
        MAX ( 'Table'[Month] ),
        FILTER (
            'Table',
            'Table'[Value] <> BLANK ()
                && 'Table'[Car] = CurrentCar
                && 'Table'[Month] <= CurrentDate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Car] = CurrentCar
                && 'Table'[Month] = LastDateWithValue
        )
    )


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

7 REPLIES 7
Stachu
Community Champion
Community Champion

if the goal is to have the table filled in you can achieve that in Power Query with few clicks
Capture.PNG



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Anonymous
Not applicable

Unfortunately the table is outside of power query, is there a solution in DAX?

Stachu
Community Champion
Community Champion

what do you mean by 'outside of Power Query'? is it calculated table?
in DAX you can try this, it works as long as Month column has type date

Value2 =
VAR CurrentCar = 'Table'[Car]
VAR CurrentDate = 'Table'[Month]
VAR LastDateWithValue =
    CALCULATE (
        MAX ( 'Table'[Month] ),
        FILTER (
            'Table',
            'Table'[Value] <> BLANK ()
                && 'Table'[Car] = CurrentCar
                && 'Table'[Month] <= CurrentDate
        )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            'Table'[Car] = CurrentCar
                && 'Table'[Month] = LastDateWithValue
        )
    )


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hi @Stachu 
I tried your code, but it says a single value for column 'car' in table cannot be determined. could you please help

Hi @Stachu ,
I have same case, but the data type of column that need to fill is "Text? type. I try to using your dax but got an erro because SUM dax can used for data type of text.

basically I have column like this, I need to fill the "status" based on previous date with same school ID.

Any help will be really appreciate.

School IDDateStatus
11 nov 2021High
21 nov 2021Medium 
31 nov 2021Low
12 nov 2021High
22 nov 2021Low
32 nov 2021 
   
   

Hi,
I have a similar situation for me with forward filling of text based on conditions. The logic with SUM works well for numeric. Your solution will greatly help me. Thanks in Advance.

Regards.

Anonymous
Not applicable

I used your query and to me, it fills the previous value to blank rows but add some garbage value to existing row value

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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