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
admin11
Memorable Member
Memorable Member

Right approach for Hard code expression for sales = year 2020 ?

Hi All

 

I have below 2 expression, i though it should be response the same behavious :-

 

I notice that below expression will be display 2020 year sales amount , even i select year = 2019 :- 

Sales_2020 = CALCULATE([SALES_], DATESYTD(DATEADD('Date'[Date],-1,YEAR)))
 

I notice that below expression will not display  2020 year sales amount , when i select year = 2019 :- 

Sales_2020_ = CALCULATE([SALES_],FILTER('Date', 'Date'[Year]=2020))
 
Can some one confirm with me pls.
 
Paul 
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

The FILTER() function will pass the baton on to the year chosen in the filter/slicer and disregard the condition specified in the CALCULATE() function.  Therefore the second measure i.e. Sales_2020_ will show the sales of 2019 (if that is what the user selects in the slicer).


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

The FILTER() function will pass the baton on to the year chosen in the filter/slicer and disregard the condition specified in the CALCULATE() function.  Therefore the second measure i.e. Sales_2020_ will show the sales of 2019 (if that is what the user selects in the slicer).


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.