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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lancersc
Helper I
Helper I

Slicer year selection in to dax measurement

CP_Price = CALCULATE(SUM(lnz_CORE[Extended Price USD]),
FILTER(lnz_CORE,lnz_CORE[Year Date]= YEAR(Today())))
 
So in this computation, my boss dwanted that the year would be selectable to any year using a filter.
How can Iink what is being chosen on a slicer to the year filter?
 
lancersc_0-1733894002005.png

CP_price should be in a specific year

PP_Price should be in a specific year

2 ACCEPTED SOLUTIONS
AnkitaaMishra
Super User
Super User

Hi @lancersc , 
you can modify your DAX as below : 

CP_Price =
VAR _selectedYear = selectedvalue(Table[year])
VAR _logic = 
CALCULATE(SUM(lnz_CORE[Extended Price USD]),
FILTER(lnz_CORE,lnz_CORE[Year Date]= _selectedYear))
RETURN
_logic

Please use the year column which you are using in slicer instead of Table[year]

Thanks, 
Ankita

View solution in original post

I did this and a version of this unfortunately it returns blank I wonder why..

 

edit.

I dont know what I did but I got it working!

I did a combination of yours and this youtube video:
https://www.youtube.com/watch?v=qlBtBme4EL4&t=396s

 

Thanks!

View solution in original post

7 REPLIES 7
govind_021
Super User
Super User

Hey  
Its simple , extract Year from the Date Column you have in Your Table
Create Calculated column by Following formula
Year = Year ( Pass Date column ) 

Then Select slicer visual from the vizualization and In fields drag  "Year" column
then it will allow the user to filter the data based on the year
make measure simple using Sum( ) formula .
Best Regards
Govind Sapkade
Data Analyst | Power BI Enthusiast | Microsoft PL 300 Certified Power BI Data Analyst | MS Fabric Enthusiast
🎥 Subscribe to my youtube channel for hands on tutorials : YouTube

📊 Let’s connect on Linkdin : Linkdin

I just added a picture of my first row table.

Unfortunately that won't work

danextian
Super User
Super User

Hi @lancersc 

Your measure should be as simple below as you're simply trying this calculation by the year column from the same table.

SUM(lnz_CORE[Extended Price USD])

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Wont't work on my tables

lancersc_0-1733893718300.png

CP_price should be in a specific year

PP_Price should be in a specific year

Do you mean that whatever year is selected from the slicer, the value for that specific measure won't change? If so, you'll need a slice modification to your formula.

CP_Price =
CALCULATE ( SUM ( lnz_CORE[Extended Price USD] ), lnz_CORE[Year Date] = 2024 )

Otherwise, please provide more context. What do you want to happen when a year from the slicer is selected?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
AnkitaaMishra
Super User
Super User

Hi @lancersc , 
you can modify your DAX as below : 

CP_Price =
VAR _selectedYear = selectedvalue(Table[year])
VAR _logic = 
CALCULATE(SUM(lnz_CORE[Extended Price USD]),
FILTER(lnz_CORE,lnz_CORE[Year Date]= _selectedYear))
RETURN
_logic

Please use the year column which you are using in slicer instead of Table[year]

Thanks, 
Ankita

I did this and a version of this unfortunately it returns blank I wonder why..

 

edit.

I dont know what I did but I got it working!

I did a combination of yours and this youtube video:
https://www.youtube.com/watch?v=qlBtBme4EL4&t=396s

 

Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.