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

Help with dax nonblank

Hi team,


I need help with a dax calculated column. I have a datetime column and value column. I need a dax calulation to take the previous nonblank value. Here is the needed result (the right column):

DateTime mm/dd/yyyy hh:mm:ss   Value   Needed Result
6/14/2022 09:00:00 PM100100
6/14/2022 10:00:00 PM107107
6/14/2022 11:00:00 PM 107
6/15/2022 00:00:00 AM 107
6/15/2022 01:00:00 AM 107
6/15/2022 01:00:00 AM200200
6/15/2022 02:00:00 AM 200
6/15/2022 03:00:00 AM300300

 

When there is empty rows, the calculation should take the previous nonblank row value and copy it,  until there is data in the value column. 

Thank you.

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous,

 

DAX to do that.

 

Column =
VAR a =
    MAXX (
        TOPN (
            1,
            FILTER (
                'Table',
                [DateTime mm/dd/yyyy hh:mm:ss]
                    < EARLIER ( 'Table'[DateTime mm/dd/yyyy hh:mm:ss] )
                    && NOT ( ISBLANK ( [Value] ) )
            ),
            [DateTime mm/dd/yyyy hh:mm:ss], DESC
        ),
        [Value]
    )
RETURN
    IF ( [Value] = BLANK (), a, [Value] )

 

 

Result:

vchenwuzmsft_0-1655798090308.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous,

 

DAX to do that.

 

Column =
VAR a =
    MAXX (
        TOPN (
            1,
            FILTER (
                'Table',
                [DateTime mm/dd/yyyy hh:mm:ss]
                    < EARLIER ( 'Table'[DateTime mm/dd/yyyy hh:mm:ss] )
                    && NOT ( ISBLANK ( [Value] ) )
            ),
            [DateTime mm/dd/yyyy hh:mm:ss], DESC
        ),
        [Value]
    )
RETURN
    IF ( [Value] = BLANK (), a, [Value] )

 

 

Result:

vchenwuzmsft_0-1655798090308.png

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

SpartaBI
Community Champion
Community Champion

@Anonymous just to be sure, you don't want to do it in Power Query? Just 2 steps

SpartaBI_0-1655382945649.png

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.