cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rajveer1117
Helper III
Helper III

Earliest Time of each hour

Hi Team,

Need help in achieving the below results.

The source data has value based on timestamp and need to find the min value of hour of time from the dataset.

Source:

Source:
TIME	VALUE
11/19/2020 15:31	167.79
11/19/2020 15:31	168.01
11/19/2020 15:21	167.7
11/19/2020 15:11	167.7
11/19/2020 15:11	167.7
11/19/2020 15:01	167.92
11/19/2020 15:01	167.7
11/19/2020 14:51	167.92
11/19/2020 14:51	167.7
11/19/2020 14:41	167.92
11/19/2020 14:41	167.7
11/19/2020 14:31	167.91
11/19/2020 14:31	167.7
11/19/2020 14:21	167.91
11/19/2020 14:20	167.7
11/19/2020 14:10	167.7
11/19/2020 14:01	167.79
11/19/2020 14:00	168.01
11/19/2020 13:50	168.01
11/19/2020 13:40	167.91
11/19/2020 13:40	167.7
11/19/2020 13:30	167.7
11/19/2020 13:30	167.7
11/19/2020 13:20	168.01
11/19/2020 13:20	168.01
11/19/2020 13:10	168.01
11/19/2020 13:00	168.01


Output:
11/19/2020 15:00	167.7
11/19/2020 14:00	168.01
11/19/2020 13:00	168.01

 

Thanks ,

Raj

1 ACCEPTED SOLUTION
v-yuaj-msft
Community Support
Community Support

Hi @rajveer1117 ,

 

Based on your description, you can do some steps as follows.

  1. Create a column to group by hour.

 

_hour = HOUR([TIME])

2. Create a measure.

 

calculated_value =

var x1=CALCULATE(MIN('Case2_2'[TIME]),ALLEXCEPT(Case2_2,Case2_2[_hour]))

return

CALCULATE(MIN('Case2_2'[VALUE]),FILTER(ALL('Case2_2'),'Case2_2'[TIME]=x1))

 

3. Create a table visual.

v-yuaj-msft_0-1606092055707.png

 

v-yuaj-msft_1-1606092055710.png

 

Result:

v-yuaj-msft_2-1606092055713.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuaj-msft
Community Support
Community Support

Hi @rajveer1117 ,

 

Based on your description, you can do some steps as follows.

  1. Create a column to group by hour.

 

_hour = HOUR([TIME])

2. Create a measure.

 

calculated_value =

var x1=CALCULATE(MIN('Case2_2'[TIME]),ALLEXCEPT(Case2_2,Case2_2[_hour]))

return

CALCULATE(MIN('Case2_2'[VALUE]),FILTER(ALL('Case2_2'),'Case2_2'[TIME]=x1))

 

3. Create a table visual.

v-yuaj-msft_0-1606092055707.png

 

v-yuaj-msft_1-1606092055710.png

 

Result:

v-yuaj-msft_2-1606092055713.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

amitchandak
Super User IV
Super User IV

@rajveer1117 , Create a column like this as suggested in last update

TIME new = [TIME].date + time(hour([TIME],0,0)

 

And then use this in visual with measure given below

firstnonblankvalue(Table[TIME], max(Table[Value]))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

As i am using the direct query , the solution above is showing error.

mahoneypat
Super User IV
Super User IV

You should be able to get your result as follows

 

- in the query editor, split your datetime column at the space and convert to date and time

- add a column by selecting your time column and in the Time pull down choose Hour

- load the table

- make a table visual with the Date column and the new hour column

- also add the Value column and choose min as the aggregation (or write a measure with MIN() )

 

Note: if you table is already loaded, you could also do the same with DAX columns, but I would do it in query.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors