Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
We are currently working on a dasboard regarding maintenance of equipment fleet.
I have a table (FACT_Partes1) with the following fields (showing data for just one equipment) regarding spare replacement: (sorted by date)
I'm trying to offset the date for each component (such dates is when the part is replaced) in order to get an "initial date" and the offseted date will be the "change date" (fecha cambio parte). Later with the initial date and change date I will read from another table the operation hours of such equipment and thus calculate the service life such component had.
I was partially able to do so by using a new function called "OFFSET" using the following code:
Fecha cambio parte =
CALCULATE(
[Fecha inicial parte],
OFFSET(
1,
ALLSELECTED(FACT_Partes1),
ORDERBY(FACT_Partes1[Fecha], ASC)
)
)
If I select only one equipment and one spare part, I get the result I want:
Last Work order should have an empty change date since the part has not been yet replaced.
BUT if I do no select any particular spare part, I get undesired results as shown below:
Clearly the OFFSET function is working since it is offseting the original table dates (which is sorted by date).
The question here is how can I "Isolate" (or group by) every spare part in order to have only change dates for such part and last change date to show empty? See mockup picture below to see desired result:
Thank you for your advice.
Solved! Go to Solution.
OFFSET only works on the current visual (or filter context if you want). In order to look up "previous" data you are better off using an index column in your data source.
OFFSET only works on the current visual (or filter context if you want). In order to look up "previous" data you are better off using an index column in your data source.
Yes, you are right.
Thanks to your advice I took a different approach:
Fecha de cambio de parte =
IF (
LOOKUPVALUE (
FACT_Partes1[SCO],
FACT_Partes1[Index], FACT_Partes1[Index]
)
= LOOKUPVALUE (
FACT_Partes1[SCO],
FACT_Partes1[Index], FACT_Partes1[Index] + 1
)
&& LOOKUPVALUE (
FACT_Partes1[Equipo],
FACT_Partes1[Index], FACT_Partes1[Index]
)
= LOOKUPVALUE (
FACT_Partes1[Equipo],
FACT_Partes1[Index], FACT_Partes1[Index] + 1
),
LOOKUPVALUE (
FACT_Partes1[Fecha],
FACT_Partes1[Index], FACT_Partes1[Index] + 1
),
MAX(FACT_Indicadores[Fecha])
)
This achieved the desired result.
Thanks a lot
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
80 | |
67 | |
59 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |