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
lovishsood1
Helper III
Helper III

Current Year and Previous year using slicer selection

Hi Team,

 

I have a table from which I'm showing data in Clustered Column Chart but my requirement is

 

If I select 2023 as a slicer value then I need to show data of 2023 and 2022 i.e., SelectedYear and SelectedYear-1.

 

I tried using this measure ;

Total Sales CY = 
var SelectedYear = SELECTEDVALUE('Raw Data'[Year])
RETURN //IN {SelectedYear,SelectedYear-1}
CALCULATE(COUNT('Raw Data'[Centre Number]),'Raw Data'[Year] IN {SelectedYear,SelectedYear-1})

I have taken Year Slicer ( Single Select).

 

Since it is Clustered Column chart so I'm not allowed to use TWO MEASURES in Y-Axis.

 

Can anybody tell me how do I do this?

6 REPLIES 6
v-zhangtin-msft
Community Support
Community Support

Hi, @lovishsood1 

 

You can try the following methods. Create a new unrelated year table.

vzhangtinmsft_0-1730873239512.png

MEASURE =
IF ( YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ) >= SELECTEDVALUE ( Year[Year] ) - 1
        && YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ) <= SELECTEDVALUE ( Year[Year] ),
    1,
    0
)

vzhangtinmsft_1-1730873357502.png

Is this the result you expected?

 

Best Regards,

Community Support Team _Charlotte

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

I tried with Date Column but now it's only showing data of 2022 and not 2023 ( On selecting either 2023 or 2024)

lovishsood1_3-1730965381853.png

PrevYear Check = 
IF (  YEAR ( SELECTEDVALUE ( 'Raw Data'[Sale Date] ))  >= SELECTEDVALUE ( YearKey[Value] ) - 1
        && YEAR ( SELECTEDVALUE ( 'Raw Data'[Sale Date] ) ) <= SELECTEDVALUE ( YearKey[Value] ),
    1,
    0
)

Hi, @lovishsood1 

 

Can you provide your example data or example files? And if there is sensitive information please remove it in advance.

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,

Community Support Team _Charlotte

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

lovishsood1_1-1730964171700.png

lovishsood1_2-1730964207156.png

Did same as you have done except the fact I have Year column and you have used Date column in your Table!!

 

Still not getting results! I even disabled the relationship of MAIN Table with Date Table.

 

Kedar_Pande
Super User
Super User

@lovishsood1 

Total Sales CY = 
VAR SelectedYear = SELECTEDVALUE('Raw Data'[Year])
RETURN
CALCULATE(
COUNT('Raw Data'[Centre Number]),
'Raw Data'[Year] IN {SelectedYear, SelectedYear - 1}
)

Add the Year field to the Axis in the Clustered Column Chart

Add Total Sales CY to the Values field

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Can you attach a snapshot where I can find the Values field in the CLUSTERED COLUMN CHART?

 

I can only see X-Axis, Y-Axis, Legend & Small Multiples!!


P.S.: You shared my DAX Measure with me!!

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.

Jan NL Carousel

Fabric Community Update - January 2025

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