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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Zosy
Helper II
Helper II

Sum of values for max year selected in slicer

Hi,

I am new at this. I have 3 tables: Sales, Budget and a date table.
Through a slicer the user selects the years they want to see and in visuals they should have Sales for selected years and Budget only for the last year selected.
If they select 2020,2021 and 2022 it should display Sales in 2020,2021 and 2022 and Budget in 2022.

How do I write in DAX the formula to only calculate the sum of budget for the max year that was selected and if there is no budget set for that year to return 0?

Sales= SUM('Invoices'[Cost])
Budget = SUM('Budget'[Value])



This is my Date table:

 

 

Date = 

VAR StartDate = DATE ( YEAR ( MIN ('Invoices'[Date]) ), 1,1)
VAR EndDate = DATE ( YEAR ( MAX ('Invoices'[Date] )), 12, 31)

return
ADDCOLUMNS(CALENDAR(
        StartDate,
        EndDate),  
        "DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ), 
        "Year", YEAR ( [Date] ), 
        "MonthNo", FORMAT ( [Date], "MM" ), 
        "YearMonthNo", FORMAT ( [Date], "YYYY/MM" ), 
        "YearMonth", FORMAT ( [Date], "YYYY/mmm" ), 
        "MonthShort", FORMAT ( [Date], "mmm" ), 
        "MonthLong", FORMAT ( [Date], "mmmm" ), 
        "WeekNo", WEEKDAY ( [Date] ), 
        "WeekDay", FORMAT ( [Date], "dddd" ), 
        "WeekDayShort", FORMAT ( [Date], "dddd" ), 
        "Quarter", "Q" & FORMAT ( [Date], "Q" ), 
        "YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date],"Q" )
)

 

 

 
 

 Your help is very much appreciated!

1 ACCEPTED SOLUTION
VijayP
Super User
Super User

@Zosy 

Try using this file and let me know if it solves  https://drive.google.com/file/d/1AOSfnqSm1qPv6L2bg4VT8GFddb3bf6wW/view?usp=sharing




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


View solution in original post

2 REPLIES 2
VijayP
Super User
Super User

@Zosy 

Try using this file and let me know if it solves  https://drive.google.com/file/d/1AOSfnqSm1qPv6L2bg4VT8GFddb3bf6wW/view?usp=sharing




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


It worked! Thank you!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.