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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Victor_Z
Frequent Visitor

YTD weekly calculation

Hi everybody,

I have a measure to calculate the YTD (year to date, since 1st January) service availability of different business process. This measure is as follows:

 

  • YTD Weekly Availability = ( (Total Elapsed Operating Time – Total Down Time) / Total Elapsed Operating Time)

Total Elapsed Operating Time = (DATEDIFF("01/01/2024",NOW(),SECOND)

 

Currently that measure is used in a table to show the current service availability for the different business processes.  Please see Picture attached 

YTD Availability.jpg

Now I want to show the trend of YTD by week, considering the time reference on the last day of the week (each Sunday).

I have managed to calculate the time elapsed operating time ( in an running total way) from January 1st to each Sunday of the elapsed weeks. I know the down time of each process for each week; however I am no able to properly calculate the running total of elapsed down time for each process (from 1st January to each Sunday of the elapsed weeks.

 

Please find attached picture YTD - weekly calculations.jpg

Summing up,  I don´t find the proper DAX calculation for the running total of elapsed down time. I always get the total down time for the week, not the accumulative running total

 

Thanks for your help or suggestions

 

1 ACCEPTED SOLUTION

Hi @amitchandak 

My mistake. Relationship between  Date Table and my date column was not OK. Now seems to be working .

Thanks a lot @amitchandak 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Victor_Z , Based on what I got, Have date table, joined it with Date part of your datetime column.

If needed create a table in you column

 

Date = Datevalue([datetime Column]) // join with date of date table 

 

Have week created column in date table

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
WeekDay = weekday([Date],2)

 

 

Use them in visual

 

And use measure

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak 

Thanks a lot , but it´s not working.

The measure is given me the Running Total up to now, but when adding to a visual a putting the weeks in the colum visual table , it keps giving the down time by week instead of the running total until each week.... so I have the same wrong calculation, YTD for each week not the running total YTD. 

Please see the difference between Power BI calculations and Excel calculations 

 

Victor_Z_1-1707477012203.png

BR

 

 

Hi @amitchandak 

My mistake. Relationship between  Date Table and my date column was not OK. Now seems to be working .

Thanks a lot @amitchandak 

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 MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.