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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

how to use a last existing value, instead of lacking row

Hello! I’m trying to find a solution for several days already. Is it possible to create a measure with logic like: if there is no data on asked date, then show the last known value from the past.

Imagine a manufacturing site filled with machines like welding machines, calibrators etc.. Each product that is being produced there has its own route and cycle time per each machine it goes through. For example, the picture below showing that selected item 10PP11-01..81 starting from 1 of Jan 2018 has Cycle time 7 seconds with 1,2,3,4 "bubble" machines. On 1st of Jan, 2019 cycle time is going to be reduced from 7 to 5 seconds for first 2 machines.image.png

Rows: Machines[machine_title]

Columns: Calendar[calendar]

Values: Assembly[cycletime]'

 

Slicer: Products[product_title]

 

 

I need to fill the empty cells with the last known value like this:Capture.JPG

 

In the Calendar table I've got all dates starting from 2018 to 2022

In the Assembly table are stored only the starting dates and values like cycle time, cycles oee and parts per cycle.

 

image.png

 

relation.JPG

 

 

How and what is the most efficient way of implementation?

Thank you

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Rather than directly placing Assembly[cycletime] into Matrix values, please add below measure:

sum cycletime =
VAR mindate =
    CALCULATE (
        MAX ( Calendar[calendar] ),
        FILTER (
            ALLSELECTED ( Assembly ),
            Machines[machine_title] = SELECTEDVALUE ( Machines[machine_title] )
                && Calendar[calendar] <= SELECTEDVALUE ( Calendar[calendar] )
                && Assembly[cycletime] <> BLANK ()
        )
    )
VAR maxdate =
    SELECTEDVALUE ( Calendar[calendar] )
RETURN
    CALCULATE (
        SUM ( Assembly[cycletime] ),
        FILTER (
            ALLSELECTED ( Assembly ),
            Machines[machine_title] = SELECTEDVALUE ( Machines[machine_title] )
                && Calendar[calendar] >= mindate
                && Calendar[calendar] <= maxdate
        )
    )

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

3 REPLIES 3
Anonymous
Not applicable

Hello! I’m trying to find a solution for several days already. Is it possible to create a measure with logic like: if there is no data on asked date, then show the last known value from the past.

Imagine a manufacturing site filled with machines like welding machines, calibrators etc.. Each product that is being produced there has its own route and cycle time per each machine it goes through. For example, the picture below showing that selected item 10PP11-01..81 starting from 1 of Jan 2018 has Cycle time 7 seconds with 1,2,3,4 "bubble" machines. On 1st of Jan, 2019 cycle time is going to be reduced from 7 to 5 seconds for first 2 machines.image.png

Rows: Machines[machine_title]

Columns: Calendar[calendar]

Values: Assembly[cycletime]'

 

Slicer: Products[product_title]

 

 

I need to fill the empty cells with the last known value like this:Capture.JPG

 

In the Calendar table I've got all dates starting from 2018 to 2022

In the Assembly table are stored only the starting dates and values like cycle time, cycles oee and parts per cycle.

 

image.png

 

relation.JPG

 

 

How and what is the most efficient way of implementation?

Thank you

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Rather than directly placing Assembly[cycletime] into Matrix values, please add below measure:

sum cycletime =
VAR mindate =
    CALCULATE (
        MAX ( Calendar[calendar] ),
        FILTER (
            ALLSELECTED ( Assembly ),
            Machines[machine_title] = SELECTEDVALUE ( Machines[machine_title] )
                && Calendar[calendar] <= SELECTEDVALUE ( Calendar[calendar] )
                && Assembly[cycletime] <> BLANK ()
        )
    )
VAR maxdate =
    SELECTEDVALUE ( Calendar[calendar] )
RETURN
    CALCULATE (
        SUM ( Assembly[cycletime] ),
        FILTER (
            ALLSELECTED ( Assembly ),
            Machines[machine_title] = SELECTEDVALUE ( Machines[machine_title] )
                && Calendar[calendar] >= mindate
                && Calendar[calendar] <= maxdate
        )
    )

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Yuliana, thank you very much!

To make it work I only had to make a separate variable 'selectedMachine' to avoid some errors.

This is the working code:

 

sum cycletime = 
VAR selectedMachine = SELECTEDVALUE(machines[m.machine_id])
VAR mindate =
    CALCULATE (
        MAX ( calendar[calendar] ),
        FILTER (
            ALLSELECTED ( assembly ),
            assembly[machine_id] = selectedMachine
            && assembly[date] <= SELECTEDVALUE ( calendar[calendar] )
            && assembly[ctime] <> BLANK ()
        )
    )
VAR maxdate =
    SELECTEDVALUE ( calendar[calendar] )
RETURN
    CALCULATE (
        AVERAGE( assembly[ctime] ),
        FILTER (
            ALLSELECTED ( Assembly ),
             assembly[machine_id] = selectedMachine
             && assembly[date]>= mindate
             && assembly[date] <= maxdate
        )
    )

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.