Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
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:
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.
How and what is the most efficient way of implementation?
Thank you
Solved! Go to Solution.
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
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.
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:
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.
How and what is the most efficient way of implementation?
Thank you
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
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 ) )
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
71 | |
70 | |
38 | |
26 | |
26 |
User | Count |
---|---|
99 | |
87 | |
45 | |
43 | |
35 |