Forum Discussion
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
- Kedar_Pande
Super User
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- lovishsood1
Resolver I
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!!
- AnonymousNot applicable
Hi, lovishsood1
You can try the following methods. Create a new unrelated year table.
MEASURE = IF ( YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ) >= SELECTEDVALUE ( Year[Year] ) - 1 && YEAR ( SELECTEDVALUE ( 'Table'[Date] ) ) <= SELECTEDVALUE ( Year[Year] ), 1, 0 )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.
- lovishsood1
Resolver I
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.
- lovishsood1
Resolver I
I tried with Date Column but now it's only showing data of 2022 and not 2023 ( On selecting either 2023 or 2024)
PrevYear Check = IF ( YEAR ( SELECTEDVALUE ( 'Raw Data'[Sale Date] )) >= SELECTEDVALUE ( YearKey[Value] ) - 1 && YEAR ( SELECTEDVALUE ( 'Raw Data'[Sale Date] ) ) <= SELECTEDVALUE ( YearKey[Value] ), 1, 0 )- AnonymousNot applicable
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.