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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

Time difference per day

Hi Everybody,

I have sample data as below. Looking to find time in mins per day & trying to show them in calender visual similar as below. How can i calculate time per day? Please help.

 

Event DateStart TimeEnd Time
12/03/202012/03/2020 11:0012/05/2020 18:27

 

susheel1347_0-1607990190965.png

 

Thanks

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi Everybody,

Solved this using similar logic @amitchandak .

 

Created a time calender table  "Date" using below M language code:

 

let
Start = Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()),-11),
End = Date.AddMonths(Start,12),
Count = Number.From(End-Start)*1440,
Calendar = Table.FromColumns({List.DateTimes(Start,Count,#duration(0,0,1,0))}, type table[DateTime=datetime]),
#"Renamed Columns" = Table.RenameColumns(Calendar,{{"DateTime", "Date"}})
in
#"Renamed Columns"

 

 

and created a column "Count" with default value 1.

 

and Created a measure "Value"

 

Value = CALCULATE(SUMX(FILTER(CROSSJOIN('Event Log','Date'),'Date'[Date] >= 'Event Log'[Start Date] && 'Date'[Date]< 'Event Log'[End Date]),'Date'[Count]))
 
Which I used to display on the calender.
 
Thanks

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Not very clear. I have blog on dividing data across day. You need take care of time part

#POWERBI: How to divide/distribute values between start date or end date or count days across months/days: https://community.powerbi.com/t5/Community-Blog/How-to-divide-distribute-values-between-start-date-or-end-date/ba-p/1503785

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks @amitchandak   for responding. My bad if I was not clear. Below is what I am looking for in detail. Hope this helps.

 

start date is 12/03/2020 11:00

end Date is  12/05/2020 18:27

 

so time active on 12/03 is : 23:59 - 11:00 = 779 mins

on 12/04 it's active full day= 1440 mins

on 12/05 : 18:27-00:00 = 1107 mins

 

so I want to display all these mins on the calendar on particular days.

 

Does your solution work if I replace the value   Column in your solution  with the time in mins?

Anonymous
Not applicable

Hi Everybody,

Solved this using similar logic @amitchandak .

 

Created a time calender table  "Date" using below M language code:

 

let
Start = Date.AddMonths(Date.StartOfMonth(DateTime.LocalNow()),-11),
End = Date.AddMonths(Start,12),
Count = Number.From(End-Start)*1440,
Calendar = Table.FromColumns({List.DateTimes(Start,Count,#duration(0,0,1,0))}, type table[DateTime=datetime]),
#"Renamed Columns" = Table.RenameColumns(Calendar,{{"DateTime", "Date"}})
in
#"Renamed Columns"

 

 

and created a column "Count" with default value 1.

 

and Created a measure "Value"

 

Value = CALCULATE(SUMX(FILTER(CROSSJOIN('Event Log','Date'),'Date'[Date] >= 'Event Log'[Start Date] && 'Date'[Date]< 'Event Log'[End Date]),'Date'[Count]))
 
Which I used to display on the calender.
 
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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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