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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
dexsonc
New Member

Finding a value for a calculation

Hello,

I have the following case, I need to search for the previous date and meter according to several criteria to calculate Oil hours.

*Asset ID

*Component

*Fluid change (find and use the date and meter where "Y" appears until the next "Y")

 

Formulas used in excel

Date last

=MAX(IF([Sampled date]<[@[Sampled date]];IF([FLUID_CHANGED]="Y";IF([@[Asset ID]]=[Asset ID];IF([@Component]=[Component];[Sampled date])))))

Meter last

=INDEX(Query1;MATCH([@[Date last]]&[@Concatenate];[Sampled date]&[Concatenate];0);COLUMN([METER]))

**Concatenate= Asset ID&Componente**

Oil hours

=[@METER]-[@[Meter last]]

 

dexsonc_4-1698965017412.png

 

Please help me perform this search and calculation in Power BI.

I share an excel with little data

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@dexsonc 

you can try this

date last = maxx(FILTER('Table','Table'[Asset ID]=EARLIER('Table'[Asset ID])&&'Table'[Sample date]<EARLIER('Table'[Sample date])&&'Table'[FLUID_changed]="Y"),'Table'[Sample date])


meter last = maxx(FILTER('Table','Table'[Asset ID]=EARLIER('Table'[Asset ID])&&'Table'[Sample date]=EARLIER('Table'[date last])),'Table'[METER])

11.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
dexsonc
New Member

Thank you very much for your response, it worked 100%, just add the comparison with the component column.

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@dexsonc 

you can try this

date last = maxx(FILTER('Table','Table'[Asset ID]=EARLIER('Table'[Asset ID])&&'Table'[Sample date]<EARLIER('Table'[Sample date])&&'Table'[FLUID_changed]="Y"),'Table'[Sample date])


meter last = maxx(FILTER('Table','Table'[Asset ID]=EARLIER('Table'[Asset ID])&&'Table'[Sample date]=EARLIER('Table'[date last])),'Table'[METER])

11.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
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