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
swtgoyal
Frequent Visitor

how to display data of previous years in years but current year data in quarters in same visual?

Hi All,

 

I need to create a visual to show revenue/growth of previous and current years. I have the date table, created today/prior flags and, current year/quarter flag. 

 

the visual should show the data at quarter/month level, i created data hierarchy so that's possisble but I am not able to display the data at year level for prior years but current year data at quarter level. 

 

Below visual shows yearly data so it works untill 2023 but since 2024 is current year, how to show 2 more bars as 2024 Q1, 2024Q2 and so on..  and same way if want to do at monthly level.. 2024 Jan, 2024 Feb and so on.. 

 

swtgoyal_0-1719349401375.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @swtgoyal 

 

Please try this:

Here I create a set of sample:

vzhengdxumsft_0-1719369060379.png

Then add 3 calculated columns:

Year/Quartor =
VAR _currentYear =
    YEAR ( TODAY () )
VAR _Year =
    YEAR ( 'Table'[Date] )
RETURN
    IF (
        _Year <> _currentYear,
        FORMAT ( [Date], "YYYY" ),
        FORMAT ( 'Table'[Date], "YYYY-Q" )
    )
Year/Month =
VAR _currentYear =
    YEAR ( TODAY () )
VAR _Year =
    YEAR ( 'Table'[Date] )
RETURN
    IF (
        _Year <> _currentYear,
        FORMAT ( [Date], "YYYY" ),
        FORMAT ( 'Table'[Date], "YYYY-MM" )
    )
Year = YEAR('Table'[Date])

vzhengdxumsft_1-1719369168400.png

Next create 2 calculated tables:

Quartor = 
SUMMARIZE('Table','Table'[Year/Quartor],'Table'[Year])
Month = 
SUMMARIZE('Table','Table'[Year/Month],'Table'[Year])

vzhengdxumsft_2-1719369212816.pngvzhengdxumsft_3-1719369220192.png

Click the Year/Quartor and select year in sort by column, and Year/Month so on 

vzhengdxumsft_4-1719369375770.png

Create the relationship between these tables:

vzhengdxumsft_5-1719369554280.png

The result is as follow:

vzhengdxumsft_6-1719369797403.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.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @swtgoyal 

 

Please try this:

Here I create a set of sample:

vzhengdxumsft_0-1719369060379.png

Then add 3 calculated columns:

Year/Quartor =
VAR _currentYear =
    YEAR ( TODAY () )
VAR _Year =
    YEAR ( 'Table'[Date] )
RETURN
    IF (
        _Year <> _currentYear,
        FORMAT ( [Date], "YYYY" ),
        FORMAT ( 'Table'[Date], "YYYY-Q" )
    )
Year/Month =
VAR _currentYear =
    YEAR ( TODAY () )
VAR _Year =
    YEAR ( 'Table'[Date] )
RETURN
    IF (
        _Year <> _currentYear,
        FORMAT ( [Date], "YYYY" ),
        FORMAT ( 'Table'[Date], "YYYY-MM" )
    )
Year = YEAR('Table'[Date])

vzhengdxumsft_1-1719369168400.png

Next create 2 calculated tables:

Quartor = 
SUMMARIZE('Table','Table'[Year/Quartor],'Table'[Year])
Month = 
SUMMARIZE('Table','Table'[Year/Month],'Table'[Year])

vzhengdxumsft_2-1719369212816.pngvzhengdxumsft_3-1719369220192.png

Click the Year/Quartor and select year in sort by column, and Year/Month so on 

vzhengdxumsft_4-1719369375770.png

Create the relationship between these tables:

vzhengdxumsft_5-1719369554280.png

The result is as follow:

vzhengdxumsft_6-1719369797403.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.

Thank you so much!

 

I created new calculated columns as suggested into the Date Table and it worked perfectly.

 

Regards,
Swati

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.