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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Mariann
New Member

Countdown of hours spent (straight line)

Hi,
I need to show a countdown of hours spend on a project - over time.

This is my data. Hrs_left is calculated in excel, but this it the calculation I would like to make in PowerBi

HeaderStart_date     End_date     Budget_hrsDuration_dayhrs_pr_dayProject_periodeHrs_leftHrs_spent
11017000006-10-202201-04-20241630054330,0206-10-202216269,9830,02
11017000006-10-202201-04-20241630054330,0207-10-202216239,9660,04
11017000006-10-202201-04-20241630054330,0208-10-202216209,9490,06
11017000006-10-202201-04-20241630054330,0209-10-202216179,92120,08
11017000006-10-202201-04-20241630054330,0210-10-202216149,9150,1
11017000006-10-202201-04-20241630054330,0211-10-202216119,88180,12
11017000006-10-202201-04-20241630054330,0212-10-202216089,86210,14
11017000006-10-202201-04-20241630054330,0213-10-202216059,84240,16
11017000006-10-202201-04-20241630054330,0214-10-202216029,82270,18
11017000006-10-202201-04-20241630054330,0215-10-202215999,8300,2
11017000006-10-202201-04-20241630054330,0216-10-202215969,78330,22
11017000006-10-202201-04-20241630054330,0217-10-202215939,76360,24
11017000006-10-202201-04-20241630054330,0218-10-202215909,74390,26
11017000006-10-202201-04-20241630054330,0219-10-202215879,72420,28
11017000006-10-202201-04-20241630054330,0220-10-202215849,7450,3

I need to show something like this - so it will be a countdown of budget hours

Mariann_0-1684151451423.png

Of course, i need these data to be accompagnied by actual spend hours, but this is not a problem - i just can't figure out how to make this "straight line countdown". 

Best regards,
Mariann

1 REPLY 1
rohit_singh
Solution Sage
Solution Sage

Hi @Mariann ,

This is pretty straightforward using DAX. 

1. Load your dataset into the data view. I have named the table 'Project'

rohit_singh_0-1684156192106.png

2. First you will need to calculate the rank of each day within a given project. This can be done by using the RANKX function and adding a calculated column as follows :

Rank =

    RANKX(
        FILTER(
            Project,
            Project[Header] = EARLIER(Project[Header])
        ),
        Project[Project_period],
        ,
        ASC
        ,

        Dense
    )
 
This will give you a ranking based on each day of the project. 
rohit_singh_1-1684156314204.png

 

3. Based on the rank calculated above, create another calculated column 'Hrs_spent ' that will give you the hours spent. This will be a running total of hours spent in the project by day.

Hrs_spent =

    CALCULATE(
        SUM(Project[hrs_pr_day]),
        FILTER(
            ALLEXCEPT(Project, Project[Header]),
            Project[Rank] <= EARLIER(Project[Rank])
        )
    )
rohit_singh_2-1684156424714.png

4. Add another calculated column 'Hrs_Left' which is simply 

Project[Budget_hrs] - Project[Hrs_spent]
 
rohit_singh_3-1684156495541.png

 

Now that you have performed all necessary calculations, open the report view and add a line chart visual. Add project_period on the X-Axis and Hrs_left on the Y-Axis and you should see the desired visual.

rohit_singh_4-1684156585531.png


Kind regards,

Rohit


Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors