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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ajet-p_91
Frequent Visitor

Need help with slicer selection dax

Hi every one 

I have a slicer with the years 2022, 2023, and 2024, and I'm tracking the total price as a key performance indicator (KPI). When I select 2023 in the slicer, I want to see the total price for both 2022 and 2023. Similarly, if I select 2024, I want to see the total price for 2022, 2023, and 2024. 

How can I set this up?

and also if i have financial year (2023-24) instead of year how can i do it 

12 REPLIES 12
ajet-p_91
Frequent Visitor

Hi @v-tianyich-msft 

if we have two slicers like year and month then how can i achieve this 

Hi @ajet-p_91 ,

 

This can be accomplished by making simple changes to his expression.

TotalSum = CALCULATE(SUM('Table'[Value]),'Table'[Date].[Year]<=SELECTEDVALUE('Table'[Date].[Year])&&'Table'[Date].[Month]<=SELECTEDVALUE('Table'[Date].[Month]))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

ajet-p_91
Frequent Visitor

Hi @v-tianyich-msft 

ajetp_91_0-1721890278358.png

ajetp_91_1-1721890312227.png

This is the result 

Current = COALESCE(CALCULATE(SUM('Table'[price]),FILTER('Table','Table'[Year].[Year]=SELECTEDVALUE('Dim Year'[Year]))),0)
Pre = COALESCE(CALCULATE(SUM('Table'[price]),FILTER('Table','Table'[Year].[Year]=SELECTEDVALUE('Dim Year'[Year])-1)),0)

Hi @ajet-p_91 ,

 

Disconnecting dimyear from date seems to work.

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-tianyich-msft 

Can you give more details about how to do it 

Hi @ajet-p_91 ,

 

Create a year dimension table and use it as a slicer to control the current year versus the previous year that needs to be calculated. Please see the attachment above.

 

Best regards,
Community Support Team_ Scott Chang

ajet-p_91
Frequent Visitor

Hi @v-tianyich-msft 

The current Dax is currently operational, but the pre-Dax is not working. Also, I want data from all previous years, not just last year.

So if I understand your requirements correctly on selecttion of year 2022 the output should be sum of total for year 2022,2023 & 2024. and incase of selection of 2023 the output should be a sum of total for 2023 and 2024.and there can be N number of years following the year that you select.

 

TotalSum = CALCULATE(SUM('Table'[Value]),'Table'[Date].[Year]>=SELECTEDVALUE('Table'[Date].[Year]))

 


1.gif



Regards,
Sachin
Check out my Blog

Hi @ajet-p_91 ,

 

Please provide sample data as well as expected results.

 

Best regards,
Community Support Team_ Scott Chang

ajet-p_91
Frequent Visitor

Hi @v-tianyich-msft 

It's not working 

 

Hi @ajet-p_91 ,

 

Where are you stuck? What kind of results are you getting?

 

Best regards,
Community Support Team_ Scott Chang

v-tianyich-msft
Community Support
Community Support

Hi @ajet-p_91 ,

 

If only one measure is used, it seems that it is only possible to realize the totals for viewing two years. It could be last year or any span of years. You can check the results below:

vtianyichmsft_0-1721872974788.png

vtianyichmsft_1-1721872984663.png

Current = CALCULATE(SUM('Date'[Value]),FILTER('Date',YEAR('Date'[Date])=SELECTEDVALUE('Dim Year'[Year])))

Pre = CALCULATE(SUM('Date'[Value]),FILTER('Date',YEAR([Date])=SELECTEDVALUE('Dim Year'[Year])-1))

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.