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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Trying to sum full year but getting error message

I have the years selected on a slicer and it am trying to sum full year budget using

 

full year = CALCULATE(SUM(Budgets[amount]),'Calendar$'[Date].[Year])

but I am receiving this error message.

 

An unexpected error occurred (file 'xlname.cpp', line 388, function 'XLNamePair::NormSubtree').An unexpected error occurred (file 'xlname.cpp', line 388, function 'XLNamePair::NormSubtree').

 

Help

 

Thanks

 

 

2 ACCEPTED SOLUTIONS
Sean
Community Champion
Community Champion

Full Year 2016 =
    CALCULATE (
        SUM ( Budgets[Amount] ),
        FILTER ( ALL ( 'Calendar$' ), 'Calendar$'[Date].[Year] = 2016 )
    )

So if your Slicer is from the Calendar table use the above!

If not this should work either way...

 

Full Year 2016 ALT =
    CALCULATE (
        SUM ( Budgets[Amount] ),
        FILTER ( ALL ( 'Budgets' ), 'Budgets'[budget_code] = 2016 )
    )

 

View solution in original post

Hi @Anonymous,



Thanks Jerry, i can see that working but the problem is we have transactions in there for next year. 

Would MAX still bring in 2016? or 2017?


What columns are you using for the "Year" Slicer and "Month" Slicer? If the columns used for the Slicers are all from your "Calendar$" table(and you should use date column of the"Calendar$" table for both your Slicers in this scenario), then the formula I provided above will sum the full year depends on your selection of the "Year" Slicer. For example, if you select "2016" for "Year" Slicer, then the MAX will bring in 2016, and the measure will sum full year of 2016.Smiley Happy

 

Regards

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Wish I could add two answers to this as it took a combination of both answers.

 

Needed to use the Filter ALL otherwise it would change on the month selected.

 

 

Full Year  = var y = MAX('Calendar$'[Year]) return 
    CALCULATE (
        SUM ( Budgets[Amount] ),
        FILTER ( ALL ( 'Calendar$' ), 'Calendar$'[Date].[Year] = y )
    )
Sean
Community Champion
Community Champion

@Anonymous Are you trying to get the current full year?

 

full year =
CALCULATE (
    SUM ( Budgets[amount] ),
    FILTER (
        ALL ( 'Calendar$' ),
        'Calendar$'[Date].[Year] = MAX ( 'Calendar$'[Date].[Year] )
    )
)

If you want to get the total for several years selected in a Slicer you may be over thinking this a simple sum would do this.

 

EDIT: Or wait I think you may be trying to achieve this...

 

full year =
CALCULATE ( SUM ( Budgets[amount] ), ALLSELECTED ( 'Calendar$' ) )
Anonymous
Not applicable

Hi Sean,

 

Thats Great!

 

Yes I am trying to sum the year selected in the slicer... will give that a try.

 

Thanks!

Anonymous
Not applicable

Thanks Sean I have tried that but thast doesnt work ...

 

Becasue the user can also select the month as well as the year i somehow need to reference the slicer?

 

I have tried

 

Full Year =
CALCULATE ( SUM ( Budgets[amount] ), DATESBETWEEN('Calendar$'[Date], STARTOFYEAR('Calendar$'[Date]),ENDOFYEAR('Calendar$'[Date])))

 

but that doesnt work either.

Hi @Anonymous,

 

According to your description, you may need to use the formula below to add a calculate column called "Year" in your "Calendar$" table first.

Year = YEAR ( 'Calendar$'[Date] )

Then, you should be able to use the formula below to create the "Full Year" measure.

Full Year =
    VAR y =
        MAX ( 'Calendar$'[Year] )
    RETURN
        CALCULATE ( SUM ( Budgets[amount] ), YEAR ( 'Calendar$'[Date] ) = y )

Regards

Anonymous
Not applicable

Thanks Jerry, i can see that working but the problem is we have transactions in there for next year.

 

Would MAX still bring in 2016? or 2017?

 

Didnt know you could have variables in DAX.. cool

Hi @Anonymous,



Thanks Jerry, i can see that working but the problem is we have transactions in there for next year. 

Would MAX still bring in 2016? or 2017?


What columns are you using for the "Year" Slicer and "Month" Slicer? If the columns used for the Slicers are all from your "Calendar$" table(and you should use date column of the"Calendar$" table for both your Slicers in this scenario), then the formula I provided above will sum the full year depends on your selection of the "Year" Slicer. For example, if you select "2016" for "Year" Slicer, then the MAX will bring in 2016, and the measure will sum full year of 2016.Smiley Happy

 

Regards

Anonymous
Not applicable

No matter what I do even

 

Full Year = 
CALCULATE ( Sum(Budgets[amount]),Budgets[budget_code]=2016)

Only returns the month selected in the slicer...I need to override it somehow?

Anonymous
Not applicable

Anyone?

Sean
Community Champion
Community Champion

Full Year 2016 =
    CALCULATE (
        SUM ( Budgets[Amount] ),
        FILTER ( ALL ( 'Calendar$' ), 'Calendar$'[Date].[Year] = 2016 )
    )

So if your Slicer is from the Calendar table use the above!

If not this should work either way...

 

Full Year 2016 ALT =
    CALCULATE (
        SUM ( Budgets[Amount] ),
        FILTER ( ALL ( 'Budgets' ), 'Budgets'[budget_code] = 2016 )
    )

 

Anonymous
Not applicable

Thanks Sean, will give that a try, take it there is no way to get it to say 2016 automatically?

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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