Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

calculate time values in one column

Hello everyone,

 

I'm new to Power BI and could use your help.

- I have an Excel sheet which contains tasks (repeating) and time stamps for end and start of task

- I want to calculate, categorize and visualize the needed times for my tasks + the waiting time inbetween two tasks

- Excel sheet looks like this 

 

TaskTime Stamp 
Task n Startdd.mm.yyyy hh:mm:ss
Task n Enddd.mm.yyyy hh:mm:ss
Task n+1 Startdd.mm.yyyy hh:mm:ss
Task n+1 Enddd.mm.yyyy hh:mm:ss
...

...

 

My goal is a table that looks like that:

 

Task 1 time needed = Task n End - Task n Start

Task 1-2 waiting time = Task n+1 Start - Task n End

 

Task 1 time neededTask 1 - 2 waiting timeTask 2 time neededTask 2-3 waiting time...
hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
............ 

 

 

 

Step 1: 

- imported this sheet in PBI

- problem: cant calculate in one column

- solution: created calculated columns containing the time stamps of each task by using a simple if formula (if [Task] = Task n; [Time Stamp]; blank() )

 

Step 2: 

- converted each calculated column into list, then back into table

- deleted empty rows

- tried to merge them back together, values are in different rows -> no calculation

 

Step 3: 

- back to before merging my tables together

- added index columns to each table

- am now able to calculate time needed for each task using calculated columns with DAX related([Index]) Formula 

- table looks like this 

 

IndexTime Stamp for Task n Startneeded time for Task n 
1dd.mm.yyyy hh:mm:sshh:mm:ss
2dd.mm.yyyy hh:mm:sshh:mm:ss

 

Step 4:

 - created new table with DAX selectcolumns([needed time for task n])

 - tried to create more calculated columns in this table for the other tasks -> ERROR

!HELP!

 

I missed out on waiting time for the next task bc its basically the same..

 

Questions:
1) is there a better solution to my mission? This one seems kind of complicated and isnt working in the end

2) in the end i want a table like shown above which im able to visualize only from the data from my excel sheet 

 

thank you in advance!

Philipp

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

    The "greenish functions" are variables, you can get more details from this blog. You can check the applied steps of source query in Power Query Editor.

    Please give some sample data in your model, later we will provide you the solution suitable for your scenario.

    Best Regards

    Rena

11 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello everyone,

     

    I'm new to Power BI and could use your help.

    - I have an Excel sheet which contains tasks (repeating) and time stamps for end and start of task

    - I want to calculate, categorize and visualize the needed times for my tasks + the waiting time inbetween two tasks

    - Excel sheet looks like this 

     

    TaskTime Stamp 
    Task n Startdd.mm.yyyy hh:mm:ss
    Task n Enddd.mm.yyyy hh:mm:ss
    Task n+1 Startdd.mm.yyyy hh:mm:ss
    Task n+1 Enddd.mm.yyyy hh:mm:ss
    ...

    ...

     

    time needed for task n = task n Start - Task n End

    waiting time for task n+1 = task n+1 Start - Task n End

    etc.

     

    Step 1: 

    - imported this sheet in PBI

    - problem: cant calculate in one column

    - solution: created calculated columns containing the time stamps of each task by using a simple if formula (if [Task] = Task n; [Time Stamp]; blank() )

    - now my PBI table looks like this 

     

    TaskTime StampTask n StartTask n EndTask n+1 StartTask n+1 End...Task n Start
    Task n Startdd.mm.yyyy hh:mm:ssdd.mm.yyyy hh:mm:ss     
    Task n Enddd.mm.yyyy hh:mm:ss dd.mm.yyyy hh:mm:ss    
    Task n+1 Startdd.mm.yyyy hh:mm:ss  dd.mm.yyyy hh:mm:ss   
    Task n+1 Enddd.mm.yyyy hh:mm:ss   dd.mm.yyyy hh:mm:ss  
    ...

    ...

    ...

     

     

     

    ...

     

    Task n Start

    dd.mm.yyyy hh:mm:ss

     

     

     

     

     

    dd.mm.yyyy hh:mm:ss

    Task n End

    dd.mm.yyyy hh:mm:ss

     

     

     

     

     

     

     

    Step 2: 

    - converted each calculated column into list, then back into table

    - deleted empty rows

    - tried to merge them back together 

    - problem: table looks like this and i still cant calculate bc values arent in one row

     

    Task n StartTask n End...
    dd.mm.yyyy hh:mm:ss  
     dd.mm.yyyy hh:mm:ss 
      ...
    dd.mm.yyyy hh:mm:ss  

     

    dd.mm.yyyy hh:mm:ss

     

     

    Step 3: 

    - back to before merging my tables together

    - added index columns to each table

    - am now able to calculate time needed for each task using calculated columns with DAX related([Index]) Formula 

    - table looks like this 

     

    IndexTime Stamp for Task n Startneeded time for Task n 
    1dd.mm.yyyy hh:mm:sshh:mm:ss
    2dd.mm.yyyy hh:mm:sshh:mm:ss

     

    Step 4:

     - created new table with DAX selectcolumns([needed time for task n])

     - tried to create more calculated columns in this table for the other tasks -> ERROR

    !HELP!

     

    I missed out on waiting time for the next task bc its basically the same..

     

    Questions:
    1) is there a better solution to my mission? This one seems kind of complicated and isnt working in the end

    2) in the end i want a table im able to visualize only from the data from my excel sheet and looks like this:

     

    Task 1 time neededTask 1 - 2 waiting timeTask 2 time neededTask 2-3 waiting time...
    hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
    hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
    hh:mm:sshh:mm:sshh:mm:sshh:mm:ss...
    ............ 

     

    thank you in advance!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    I created a sample pbix file base on your requirement, please check if that is what you want. If no, please provide some sample data and your desired result. And if it involve any other calculation, please provide the related calculation logic. Thank you.

    Best Regards

    Rena

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous Rena,

       

      Thanks for your reply and your help.

      The final table 2) you created looks exactly like i wanted it. 

      Problem is your source table, you created 2 columns with End and Start of each task, my source table only contains one column "Time Stamp" with End and Start in one column.

       

       

      Sorry it's in German "Nomenklatur" are my tasks, i created a model with just 5 tasks, repeating 2 times.

       

      My first step was to separate Start and End of my tasks, i created tables for each task.

      I can now calculate between them but cant find a way to create the final table containing all tasks with all calulacted times.

       

       

      I can now calculate between them but cant find a way to create the final table containing all tasks with all calulacted times.

      "Intervall" is my time needed for a task for simplifying reasons i missed out on waiting times in the first model.

       

      Thank you in advance!

       

      Kind Regards 
      Philipp

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        The "greenish functions" are variables, you can get more details from this blog. You can check the applied steps of source query in Power Query Editor.

        Please give some sample data in your model, later we will provide you the solution suitable for your scenario.

        Best Regards

        Rena