Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

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

  • Anonymous's avatar
    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%
  • Anonymous's avatar
    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