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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sanket03
Regular Visitor

I want to create a clustered column chart for YoY comparison

I want to create a clustered column chart for YoY comparison where the current year data should be filtered based on month selection but for Previous year it should show entire fiscal year 

 

NOTE : Fiscal year is April to March 

5 REPLIES 5
Anonymous
Not applicable

Hi @Sanket03 

 

Please try this:

First of all, add a new calculated table:

Table 3 = 
	SUMMARIZE(
		SELECTCOLUMNS(
			'Table',
			"Y_M", FORMAT(
				'Table'[Date],
				"YYYY-MM"
			)
		),
		[Y_M]
	)

Then add a measure:

MEASURE =
VAR _Slicer_month =
    VALUE ( MID ( SELECTEDVALUE ( 'Table 3'[Y_M] ), 6, 2 ) )
VAR _Slicer_year =
    VALUE ( MID ( SELECTEDVALUE ( 'Table 3'[Y_M] ), 1, 4 ) )
RETURN
    IF (
        _Slicer_month >= 4,
        IF (
            MAX ( 'Table'[Date] )
                >= DATE ( _Slicer_year - 1, 4, 1 )
                && MAX ( 'Table'[Date] )
                    < DATE ( _Slicer_year, _Slicer_month + 1, 1 ),
            [Current]
        ),
        IF (
            MAX ( 'Table'[Date] )
                >= DATE ( _Slicer_year - 2, 4, 1 )
                && MAX ( 'Table'[Date] )
                    < DATE ( _Slicer_year, _Slicer_month + 1, 1 ),
            [Current]
        )
    )

You can change the [Current] into your own measure such as [Current Year] and [Prior Year].

Create a slicer with the Field [Y_M] from the 'Table 3', the result is as follow:

vzhengdxumsft_1-1728549900297.pngvzhengdxumsft_0-1728549842359.png

 

Best Regards

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

Sanket03
Regular Visitor

Thanks a lot for suggesting this solution.

My requirement is based on Year and Month Selection for e.g. If I select 2024 and July then I should get data from April to July 2024 and also the entire fiscal year of 2023

Sanket03_1-1728541895944.png

 

 

Unforuntely it didnt work as I want it to be displayed it in Clustered Column Chart for CY and PY. I tried using a reference Date table but I could only achieve below solution but this is not the actual ask.

Sanket03_0-1728574139951.png

 

 

Anonymous
Not applicable

Hi @Sanket03 

 

Could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

 

 

Best Regards

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

Anonymous
Not applicable

Hi @Sanket03 

 

Please try this:

Here I create a set of sample:

Table:

vzhengdxumsft_0-1728524197483.png

Then add a calculated table:

Table 2 = 
	SELECTCOLUMNS(
		GENERATESERIES(
			YEAR(MIN('Table'[Date])) - 1,
			YEAR(MAX('Table'[Date])),
			1
		),
		"Fiscal Year", [Value] & "-" & [Value] + 1
	)

vzhengdxumsft_1-1728524254136.png

Then add 2 measures:

CurrentYear =
VAR _start =
    MID ( SELECTEDVALUE ( 'Table 2'[Fiscal Year] ), 1, 4 )
RETURN
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER (
            'Table',
            'Table'[Date] >= DATE ( _start, 4, 1 )
                && 'Table'[Date]
                    < DATE ( _start + 1, 4, 1 )
        )
    )
PreviousYear =
VAR _start =
    MID ( SELECTEDVALUE ( 'Table 2'[Fiscal Year] ), 1, 4 )
RETURN
    CALCULATE (
        SUM ( 'Table'[Values] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date]
                >= DATE ( _start - 1, 4, 1 )
                && 'Table'[Date] < DATE ( _start, 4, 1 )
        )
    )

Create a Clustered column chart:

vzhengdxumsft_2-1728524387586.png

Then you can drag the field 'Table'[Date] into the Filters on this visual in the filter pane:

vzhengdxumsft_3-1728524560658.png

When you filter the date, the [PreviousYear] will not be affected:

vzhengdxumsft_4-1728524818725.png

 

 

Best Regards

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.