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

View all the Fabric Data Days sessions on demand. View schedule

Reply
jhd
Helper I
Helper I

Cumulative of measure using DATESYTD returning zero

Hi, I am trying to calculate the cumulative of a measure I have created. I have had success in the past doing this using:

 

CALCULATE(
[measure],
DATESYTD('Calendar'[Date],"3/31"),
VALUES('Calendar'[FMName])
)

In other words, a running total for the fiscal year (FMName), which ends on March 31st.

 

However, it is not working for for one of my measures, and returns zero for all time periods.

 

VAR FIRSTMONTH =
CALCULATE (
MIN (MASTER_DATA[DATE_REC(FYMonth Index)]),
ALL ( MASTER_DATA[SUPPLIER_NO], MASTER_DATA[ACT], MASTER_DATA[PLANT] ,MASTER_DATA[CURR],MASTER_DATA[UOM],MASTER_DATA[DATE_REC]),
ALL(Plants),
ALLEXCEPT('Calendar','Calendar'[FYName]),
MASTER_DATA[M_UNITS_REC] > 0
) 

RETURN
SUM(MASTER_DATA[M_UNITS_REC])*
DIVIDE(
    CALCULATE(
        [GBP_VALUE],
        VALUES('Calendar'[FYName]),
        ALL(Plants),
        ALL(MASTER_DATA[CURR], MASTER_DATA[ACT], MASTER_DATA[PLANT], MASTER_DATA[SUPPLIER_NO], MASTER_DATA[UOM]),
        ALL('Calendar'),
        'Calendar'[Fiscal_Month_Number]=FIRSTMONTH
    ),
    CALCULATE(
        SUM(MASTER_DATA[M_UNITS_REC]),
        VALUES('Calendar'[FYName]),
        ALL(Plants),
        ALL(MASTER_DATA[CURR], MASTER_DATA[ACT], MASTER_DATA[PLANT], MASTER_DATA[SUPPLIER_NO], MASTER_DATA[UOM]),
        ALL('Calendar'),
        'Calendar'[Fiscal_Month_Number]=FIRSTMONTH
    )
)

 

By testing various parts of the measure, I believe the issue is with the variable FIRSTMONTH.

 

Any ideas why this is happening?

 

Thanks, James

 

1 ACCEPTED SOLUTION
jhd
Helper I
Helper I

I found this reply from @OwenAuger on another thread:

https://community.powerbi.com/t5/Desktop/Replacing-lt-year-end-date-gt-in-TOTALYTD-Function-with-TOD...

 

In short, the problem is that DATESYTD cannot handle dynamic variables.

 

I have therefore fixed the problem by using filters instead of DATESYTD

CALCULATE(
[£APV(GID)],
FILTER(
    ALL('Calendar'),
    AND(
        'Calendar'[Fiscal_Month_Number]<=MAX('Calendar'[Fiscal_Month_Number]),
        'Calendar'[Fiscal_Year]=MAX('Calendar'[Fiscal_Year])
    )
)
)

 

 

View solution in original post

1 REPLY 1
jhd
Helper I
Helper I

I found this reply from @OwenAuger on another thread:

https://community.powerbi.com/t5/Desktop/Replacing-lt-year-end-date-gt-in-TOTALYTD-Function-with-TOD...

 

In short, the problem is that DATESYTD cannot handle dynamic variables.

 

I have therefore fixed the problem by using filters instead of DATESYTD

CALCULATE(
[£APV(GID)],
FILTER(
    ALL('Calendar'),
    AND(
        'Calendar'[Fiscal_Month_Number]<=MAX('Calendar'[Fiscal_Month_Number]),
        'Calendar'[Fiscal_Year]=MAX('Calendar'[Fiscal_Year])
    )
)
)

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors