Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Good Day
I need assistance with adding a Calulcated Column to my Database.
I need worked hours to take the SMR (Hour Meter) from the day it is recorded and subtract it from the SMR of that "same machine" on the shift, and if it is the last shift then the previous day on the first shift. I think I have come right with a formula, but I need to further indicate to it to only subtract once it finds a row with the same EIID as its own.
Solved! Go to Solution.
Hi @Anonymous ,
You can use VAR to improve preformance.
Previous SMR =
VAR _t =
TOPN (
1,
FILTER (
DailyProduction,
DailyProduction[EIID] = EARLIER ( DailyProduction[EIID] )
&& DailyProduction[SMR] < EARLIER ( DailyProduction[SMR] )
),
[Date], DESC
)
RETURN
MAXX ( _t, [SMR] )
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Just to expand, I woudl essentally want the 6911 to rather be the result of the 16298-16294. Then the 2nd line would need to subtract 16294 from the lowest in the shift which would be 16293.
Would it be easier to use a function that sorts the data before calculating?
Hi @Anonymous ,
Don't quite understand your explanation. Can you give simple data and include the expected output values? It is best to share it in a tabular format.
Or you can try this expression:
Column =
VAR _last =
TOPN (
1,
FILTER (
'Table',
[EIID] = EARLIER ( 'Table'[EIID] )
&& [date&shift] < EARLIER ( 'Table'[date&shift] )
),
[date&shift], DESC
)
RETURN
IF ( COUNTROWS ( _last ) > 0, [Shift] - MAXX ( _last, [Shift] ) )
Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You can use VAR to improve preformance.
Previous SMR =
VAR _t =
TOPN (
1,
FILTER (
DailyProduction,
DailyProduction[EIID] = EARLIER ( DailyProduction[EIID] )
&& DailyProduction[SMR] < EARLIER ( DailyProduction[SMR] )
),
[Date], DESC
)
RETURN
MAXX ( _t, [SMR] )
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks a lot! It still takes a while to run but I think that is just the nature of the calculation I am doing. I am changing the actual input of the database to include this number already so that I don't have to calculate it via formula.
Thanks again
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |