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

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.

Reply
Anonymous
Not applicable

Calculate Previous Minute Values

Hi All,

 

I have a table which contains current and voltages values for each 3 minutes of intervel.

I would like to calculate the previous minute value from the current minute value.

 

Sample data looks as like below table.

 

KEYTimeVALUE

Input Current L111:00:00 AM20
Input Current L111:03:00 AM34
Input Current L111:06:00 AM43
Input Current L111:09:00 AM58
Input Current L111:12:00 AM53
Input Voltage L111:00:00 AM230
Input Voltage L111:03:00 AM145
Input Voltage L111:06:00 AM170
Input Voltage L111:09:00 AM240
Input Voltage L111:12:00 AM280
Output Voltage L111:00:00 AM230
Output Voltage L111:03:00 AM233
Output Voltage L111:06:00 AM232
Output Voltage L111:09:00 AM231
Output Voltage L111:12:00 AM230
Output Current L111:00:00 AM23
Output Current L111:03:00 AM24
Output Current L111:06:00 AM25
Output Current L111:09:00 AM25
Output Current L111:12:00 AM26

 

I tried the below formula to get the previous minute 

Previous Minute = MAXX(FILTER(ALL(Sheet2),[Time]<EARLIER([Time])),[Time])

 

And i got the previous minutes.

 

I tried to get the previous values using the same method but i couldnt. i am getting the wrong values.

Previous Value = 
VAR pre = MAXX(FILTER(ALL(Sheet2),[Time]<EARLIER([Time])),[Time])
RETURN 
MINX(FILTER(ALL(Sheet2),Sheet2[Time]=pre),[VALUE])

Output:-

1.PNG

 2.PNG

Can any one please correct me..

 

Thank you.

Mohan V 

 

 

 

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Please try this

 

Previous Value = 
VAR pre = MAXX(FILTER(ALL(Sheet2),[Time]<EARLIER([Time])),[Time])
RETURN 
MINX(FILTER(Sheet2,Sheet2[Time]=pre && 'Sheet2'[Key] = EARLIER('Sheet2'[Key])),[VALUE])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

2 REPLIES 2
Phil_Seamark
Employee
Employee

Hi @Anonymous

 

Please try this

 

Previous Value = 
VAR pre = MAXX(FILTER(ALL(Sheet2),[Time]<EARLIER([Time])),[Time])
RETURN 
MINX(FILTER(Sheet2,Sheet2[Time]=pre && 'Sheet2'[Key] = EARLIER('Sheet2'[Key])),[VALUE])

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Anonymous
Not applicable

@Phil_Seamark That was quick and cool...

Thanks..:):)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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