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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
Employee
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
Employee
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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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