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
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

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/

 

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

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
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.

Top Solution Authors