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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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