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

I want to choose the temperature value of the closest minute to the hour

I have a temperature sensor that measures temprature every some minute and I want to choose the temperature value of the closest minute to the hour.How Can I do that?

For example, for 23 o'clock I want to choose the value of the closest minute to 23 o'clock. 

Skärmklipp.PNG

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi Samrawit21,

 

Create a measure to achieve the minimum interval using DAX below:

Minimun Interval Column = 
VAR temp = ABS(ABS(DATEDIFF(DATE(2018, 6, 9), MIN(Table1[Dateum]), SECOND)) - 23 * 60 * 60)
VAR hour = ROUNDDOWN(temp / 3600, 0)
VAR minute = ROUNDDOWN((temp - hour * 3600) / 60, 0)
VAR second = MOD(temp, 60)
RETURN
TIME(hour, MINUTE, second)

Capture.PNG 

 

Then obviously you can find the nearest date, just sort [Minimum Interval Column]

 

Regards,

Jimmy Tao

Anonymous
Not applicable

I want to write a function which chooses the temperature value of each hour. in the attached image of my previous question, you can see that the sensor measures every 5 minutes so the function should choose one value when the minute is close to the hour.
for example 06/09/2018 23:14:41 is close to 23:00 so the function must choose the temperature value of that time, and 06/09/2018 23:59:48 is close to 00:00:00(12:00 AM)...

I hope my question is clear enough.

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.