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! Learn more

Reply
Jan_Trummel
Helper IV
Helper IV

Read out the last valid value

Hello community,


I need a measure that always reads the last valid value from a table.

 

I have the following data in my table Factors:

Table "Factors"Table "Factors"

As you can see, I don't have a factor in my table for every day.

But now I need a measure for a later calculation that gives me the last factor value for each day in the dimDate table.

The whole thing should look like this (displayed once in Excel). The different colors should help you to understand what exactly I want to achieve:

The result as it might look in ExcelThe result as it might look in Excel

I have created the following measures in Power BI Desktop:

 

The first measure simply sums the values in the Factors[Factor] column.

Sum Factors = SUM(Factors[Factor])

 

The next measure actually does the job, but quickly becomes very slow with larger amounts of data:

Factor every day =

VAR vDate = MAX(DimDate[Date])

VAR vResult =

CALCULATE(

    [Sum Factors],

    LASTNONBLANK(

        FILTER(

            ALL(DimDate[Date]),

            DimDate[Date] <= vDate

        ),

        [Sum Factors]

    )

)

RETURN

vResult

Here is the result:

The measure does what it is supposed to do, but becomes very slow with larger amounts of dataThe measure does what it is supposed to do, but becomes very slow with larger amounts of data

I suspect that the calculation is so slow because of the two iterators LASTNONBLANK and FILTER.

 

Do you have any idea how I can speed up the calculation?

 

Thank you and have a nice day!

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Jan_Trummel , Try like

CALCULATE(
LASTNONBLANK(DimDate[Date],[Sum Factors]),
FILTER(

ALL(DimDate[Date]),

DimDate[Date] <= max(DimDate[Date])

)

)

 

 

Else you have to create a table using generate

Table 2 = GENERATE(ADDCOLUMNS('Table', "Next", COALESCE( minx(filter('Table', [Column1] >EARLIER('Table'[Column1])), [Column1]),TODAY())), GENERATESERIES([Column1], [Next]))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak  and thanks a lot for your answer!

 

I slightly adjusted the measure by using LASTNONBLANKVALUE instead of LASTNONBLANK.

 

Factor every das= 

CALCULATE(

    LASTNONBLANKVALUE(

        DimDate[Date],

        [Sum Factors]

    ),

    FILTER(

        ALL(DimDate[Date]),

        DimDate[Date] <= MAX(DimDate[Date])

    )

)
 
The reason is that LASTNONBLANK gives the date but I need the result of [Sum Factors].
 
The measure also works very well in the demo data. In the production system, however, the calculation still takes a relatively long time. Do you have any other ideas?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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