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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Norbertus
Helper V
Helper V

Salesbudget per month to amount Ytd

Hi,

 

We have a table with the salesbudgets per year / month.

 

Now we want to calculate the amount with a YtD function into account the workdays in that month

 

example measure date = 15 januari 2018

budget januar 2018 => €100.000

workdays januari 2018 => 23 day (monday to friday)

workdays to 15 januari 13 days

 

YtD => €100.000 / 23 * 13 = €56.521,-

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Norbertus,

 

If I understand you correctly, you should be able to follow steps below to create the measure. Smiley Happy

 

1. Add an "IsWorkingDay" column in your Calendar table. If you don't have a Calendar table yet, you'll need create it first.

 

2. Then use the formular below to create the measure.

Measure =
VAR currentDate =
    MAX ( Date[Date] )
VAR currentYear =
    YEAR ( currentDate )
VAR currentMonth =
    MONTH ( currentDate )
RETURN
    SUM ( 'Table1'[budget] )
        * DIVIDE (
            CALCULATE (
                COUNTROWS ( Date[Date] ),
                FILTER (
                    ALL ( Date ),
                    YEAR ( Date[Date] ) = currentYear
                        && MONTH ( Date[Date] ) = currentMonth
                        && Date[Date] <= currentDate
                        && Date[IsWorkingDay] = 1
                )
            ),
            CALCULATE (
                COUNTROWS ( Date[Date] ),
                FILTER (
                    ALL ( Date ),
                    YEAR ( Date[Date] ) = currentYear
                        && MONTH ( Date[Date] ) = currentMonth
                        && Date[IsWorkingDay] = 1
                )
            )
        )

Reference:

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/19/working-days-computation-in-powerpivot.a...

https://blog.andredevelopment.com/post/power-bi-working-days-and-holiday-calendars

 

Regards

View solution in original post

1 REPLY 1
v-ljerr-msft
Employee
Employee

Hi @Norbertus,

 

If I understand you correctly, you should be able to follow steps below to create the measure. Smiley Happy

 

1. Add an "IsWorkingDay" column in your Calendar table. If you don't have a Calendar table yet, you'll need create it first.

 

2. Then use the formular below to create the measure.

Measure =
VAR currentDate =
    MAX ( Date[Date] )
VAR currentYear =
    YEAR ( currentDate )
VAR currentMonth =
    MONTH ( currentDate )
RETURN
    SUM ( 'Table1'[budget] )
        * DIVIDE (
            CALCULATE (
                COUNTROWS ( Date[Date] ),
                FILTER (
                    ALL ( Date ),
                    YEAR ( Date[Date] ) = currentYear
                        && MONTH ( Date[Date] ) = currentMonth
                        && Date[Date] <= currentDate
                        && Date[IsWorkingDay] = 1
                )
            ),
            CALCULATE (
                COUNTROWS ( Date[Date] ),
                FILTER (
                    ALL ( Date ),
                    YEAR ( Date[Date] ) = currentYear
                        && MONTH ( Date[Date] ) = currentMonth
                        && Date[IsWorkingDay] = 1
                )
            )
        )

Reference:

http://sqlblog.com/blogs/alberto_ferrari/archive/2011/01/19/working-days-computation-in-powerpivot.a...

https://blog.andredevelopment.com/post/power-bi-working-days-and-holiday-calendars

 

Regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.