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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jitpbi
Post Patron
Post Patron

specific time from datetime field

Hi,

 

from the below sample data, i need to display the values on the visual only for the time period 10:00 AM to 04:00 PM:

 

DateTime   Predicted ValueActual ValueVariation

9/8/2020 6:10:00 AM

100964
9/6/2020 8:10:00 AM991056
9/7/2020 10:20:00 AM101974
9/8/2020 12:02:00 PM98908
9/6/2020 3:32:00 PM96982
9/8/2020 04:00:00 PM100955
9/8/2020 06:02:00 PM82757
9/7/2020 08:02:00 PM54504
9/6/2020 11:11:00 PM30282

 

Any suggestion to acheive this really appreciated.

 

Thanks

1 ACCEPTED SOLUTION

@jitpbi ,

In power query you can use Time.Hour

Time.Hour([Datetime])

if you want to remove data you can now filter between 10 to 16 

 

if Time.Hour([Datetime])  >=10 and Time.Hour([Datetime])  <=16 then 1 else 0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@jitpbi , Better you create a time column or use [Datetime].time in place ot time

 

time = [DateTime].time

Create formula for all measure you need

example
Predicted value M =calculate(Sum(Table[Predicted Value ]) , filter(Table, Table[time]>=time(10,0,0) && Table[Time]<=Time(16,0,0)))

Actual Value M =calculate(Sum(Table[Actual Value]) , filter(Table, Table[time]>=time(10,0,0) && Table[Time]<=Time(16,0,0)))

 

Or Create a time table. Join with table and use that as a filter.  You can column of 24 Hours and use a range too

https://kohera.be/blog/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak ,

 

Just thinking to do it in the edit query, if we can select from the datetime field for the time 10 AM to 4 PM. So the data will be loaded for 10 AM to 4 PM only. Can you please help me to do this in power query.

 

Thanks

 

 

@jitpbi ,

In power query you can use Time.Hour

Time.Hour([Datetime])

if you want to remove data you can now filter between 10 to 16 

 

if Time.Hour([Datetime])  >=10 and Time.Hour([Datetime])  <=16 then 1 else 0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak ,

 

I am gettiing another challenege after republishing the report to service, where i replaced with the existing dataset, the "hour" column is not showing in the table. Also getting the data for entire time as before not for the time (>=10 &<= 16) i filtered in the power query. The same file in desktop was working fine where hour column is there in the table and data is filtered for the time >=10 &<= 16.

Can you please suggest what would be the reason and how to resolve this.

 

Thanks 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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