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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
davaru
Frequent Visitor

YTD example

Hi everibody.

I have the following measure

YTD Capacity Hours = CALCULATE( TOTALYTD( SUM(Capacity[capacity]) , Dates[Date] ) ,  
                                ALL(Dates) ,
                                FILTER( Capacity, Capacity[idemployee] < "30000"  && Capacity[functional_type] = "Consulting"    )
                                )

table Capacity (date, capacity, idemployee, functiona_type,......)

I hope to receive the sum of capacity for the last year load into the table (exmpl loaded up to 31-03-2017)

 

I have defined a time slicer on Dates (i can select differents months between jan 2016 and march 2017)  the results vary on selection.

 

How can help me

thnks in advance

david

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @davaru,

 

If the date slicer is set to "Between", and the date column is dragged from calendar table, you can refer to below formulas.

Dates =
CALENDAR ( MIN ( Capacity[date] ), MAX ( Capacity[date] ) )

YTD Capacity =
CALCULATE (
    TOTALYTD ( SUM ( 'Capacity'[capacity] ), 'Dates'[Date] ),
    ALL ( 'Dates' ),
    FILTER (
        'Capacity',
        'Capacity'[idemployee] < 30000
            && 'Capacity'[functional_type] = "Consulting"
    )
)

LY YTD Capacity =
CALCULATE ( [YTD Capacity Hours], SAMEPERIODLASTYEAR ( Dates[Date] ) )

1.PNG

2.PNG

 

However, if the date slicer is set to "List", you need an extra calendar table. You should drag date column from 'Dates2'.

YTD =
CALCULATE (
    SUM ( Capacity[capacity] ),
    DATESYTD ( Dates[Date] ),
    FILTER (
        Capacity,
        Capacity[idemployee] < 30000
            && Capacity[functional_type] = "Consulting"
            && Capacity[date] <= MAX ( Dates2[Date] )
    )
)

YTD LY =
CALCULATE (
    [YTD],
    SAMEPERIODLASTYEAR (
        INTERSECT (
            VALUES ( Dates[Date] ),
            DATESBETWEEN ( Dates[Date], BLANK (), MAX ( Dates2[Date] ) )
        )
    )
)

3.PNG

4.PNG

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @davaru,

 

If the date slicer is set to "Between", and the date column is dragged from calendar table, you can refer to below formulas.

Dates =
CALENDAR ( MIN ( Capacity[date] ), MAX ( Capacity[date] ) )

YTD Capacity =
CALCULATE (
    TOTALYTD ( SUM ( 'Capacity'[capacity] ), 'Dates'[Date] ),
    ALL ( 'Dates' ),
    FILTER (
        'Capacity',
        'Capacity'[idemployee] < 30000
            && 'Capacity'[functional_type] = "Consulting"
    )
)

LY YTD Capacity =
CALCULATE ( [YTD Capacity Hours], SAMEPERIODLASTYEAR ( Dates[Date] ) )

1.PNG

2.PNG

 

However, if the date slicer is set to "List", you need an extra calendar table. You should drag date column from 'Dates2'.

YTD =
CALCULATE (
    SUM ( Capacity[capacity] ),
    DATESYTD ( Dates[Date] ),
    FILTER (
        Capacity,
        Capacity[idemployee] < 30000
            && Capacity[functional_type] = "Consulting"
            && Capacity[date] <= MAX ( Dates2[Date] )
    )
)

YTD LY =
CALCULATE (
    [YTD],
    SAMEPERIODLASTYEAR (
        INTERSECT (
            VALUES ( Dates[Date] ),
            DATESBETWEEN ( Dates[Date], BLANK (), MAX ( Dates2[Date] ) )
        )
    )
)

3.PNG

4.PNG

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thnks.

Good solutions It works

Tnks again

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors