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

Need help

Hi everyone

I need help with writing one or multiple dax formula to do the following 

My dataset looks like this :

OperationStart dateStart timeEnd dateEnd time  
00101/01/202208:0501/01/202209:12  
00201/01/202209:0401/01/202210:12  
00302/01/202214:1202/01/202214:14  
00408/03/202213:1408/03/202213:58  
00515/04/202217:1515/04/202218:01  

As you can see I have multiple transaction per day. I need:

1- Calculate the available time per month which is the sum of the available time per day (available time per day = end time of the last transaction - start time of the first transaction). Days where there are no transactions the available time is assumed to be 8h

2- Calculate usage per month which is the sum of the usage per day which is the sum of the durations of every transaction (duration of every transaction = end time - start time
3- Calculate the usage % per month which is usage per month / available time per month 

Let me know if you need any other information 

5 REPLIES 5
Anonymous
Not applicable

I figured creating a date tabel is my best option here. I will reformulate my problem as follow 

My facts tables is as follows 

Transaction #Start DateStart timeEnd DateEnd timeDuration
00000101/01/202208:1301/01/202209:050.87
00000201/01/202216:2801/01/202217:250.95
00000303/01/202209:1502/01/202210:020.78

My output date table will be as follows

DateUsageAvailable timeUsage %
01/01/20221.8216 (8<9.2<16)11.38%
02/01/20220.788 (0.78<8)9.75%

- Usage is the sum of durations (end time - start time) of each transaction 

- Available time is end time of last transaction - start time of first transaction. We have 3 scenarios for this:

If it's less than 8h it will be 8h

if it's more than 8h but less than 16h it will be 16h

If it's more than 16h it will be the value found 

Note: Available time on saturdays and sundays will be 0 if it's less than 8h or the value found if it's more than 0 

- Usage % is usage/available time 

 

I would like to show the totals by month also 

 

Thank you 

mangaus1111
Solution Sage
Solution Sage

Hi @Anonymous ,

 

see my solution on the pbi File. Let me know if you can not open the link.

 

https://1drv.ms/u/s!Aj45jbu0mDVJiHRJvAMfvPPe444G?e=UCv3OP

 

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

 

Anonymous
Not applicable

I forgot to mention. For days where there are transactions, if available time is less than 8h it will be considered 8h. otherwise it's the result of the calculation last transaction time - first transaction time

Ultimately I want to have a table as follows :

DateUsageAvailable timeUsage %
01/01/20222.25828.25%
02/01/20220.0380.375%
03/01/2022080%
Total2.28249.5%

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

For the sample data that you have shared, show the expected result. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.