Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Calculating Hourly Supply

This is what my table looks like before filtering by any person to see how many hours they worked. 

 

After filtering by a person that worked from 12am to 8am on a particular date, lets say 02/11/2024 here is what I have 

((Total of 8hrs in the  12AM Column).

 

 

The challenge I have is that I want the entire 8 hours to be spread across from 12am to 8am something like this. i created this in word for better illustration

 

 

 

2 Replies

  • Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

    Do not include sensitive information or anything not related to the issue or question.

    If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

    Please show the expected outcome based on the sample data you provided.

    Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi lbendlin ,thanks for the quick reply.

    Hi lamlamm24 ,

    Please follow these steps:
    1. Use the following DAX expression to create a table

    Table  = GENERATESERIES(TIME(1,0,0),TIME(8,0,0),TIME(1,0,0))

    2. Use the following DAX expression to create a column(‘HourSupply’: Sum of hours worked after filtering with clinicians on specific dates, I'm assuming a figure of 8.)

    Column = DIVIDE([HourSupply] ,8)

    3.Use the following DAX expression to create a column

    Column2 = SWITCH(TRUE(),
    [Value] = TIME(1,0,0),"12am-12:59am",
    [Value] = TIME(2,0,0),"1am-1:59am",
    [Value] = TIME(3,0,0),"2am-2:59am",
    [Value] = TIME(4,0,0),"3am-3:59am",
    [Value] = TIME(5,0,0),"4am-4:59am",
    [Value] = TIME(6,0,0),"5am-5:59am",
    [Value] = TIME(7,0,0),"6am-6:59am",
    [Value] = TIME(8,0,0),"7am-7:59am"
    )

    4.Final output