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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Hermarian
Regular Visitor

Show values by quarter and year

Hi, I have a Matrix visual where I have data for two years, but I want to show quarter data only for the current year and keep prior year as one column only. How do I go about this? 

Thank you

Hermarian_0-1708700941296.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Hermarian 


Please try this:

First of all, I create a set of sample:

vzhengdxumsft_0-1708929351932.png

Then create a new table:

Table 2 = {"_Last year","1Q","2Q","3Q","4Q"}

Then add a measure:

MEASURE =
VAR _newValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _MaxYear =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR _currentQuarter =
    QUARTER ( MAX ( 'Table'[Date] ) )
VAR _Sumvalue =
    SWITCH (
        _newValue,
        "_Last year",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER ( ALLSELECTED ( 'Table' ), YEAR ( 'Table'[Date] ) = _MaxYear - 1 )
            ),
        "1Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 1
                )
            ),
        "2Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 2
                )
            ),
        "3Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 3
                )
            ),
        "4Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 4
                )
            )
    )
RETURN
    _Sumvalue

The result is as follow:

vzhengdxumsft_1-1708929461935.png

If the above one can't help you, 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.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Hermarian 


Please try this:

First of all, I create a set of sample:

vzhengdxumsft_0-1708929351932.png

Then create a new table:

Table 2 = {"_Last year","1Q","2Q","3Q","4Q"}

Then add a measure:

MEASURE =
VAR _newValue =
    SELECTEDVALUE ( 'Table 2'[Value] )
VAR _MaxYear =
    YEAR ( MAX ( 'Table'[Date] ) )
VAR _currentQuarter =
    QUARTER ( MAX ( 'Table'[Date] ) )
VAR _Sumvalue =
    SWITCH (
        _newValue,
        "_Last year",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER ( ALLSELECTED ( 'Table' ), YEAR ( 'Table'[Date] ) = _MaxYear - 1 )
            ),
        "1Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 1
                )
            ),
        "2Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 2
                )
            ),
        "3Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 3
                )
            ),
        "4Q",
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    YEAR ( 'Table'[Date] ) = _MaxYear
                        && QUARTER ( 'Table'[Date] ) = 4
                )
            )
    )
RETURN
    _Sumvalue

The result is as follow:

vzhengdxumsft_1-1708929461935.png

If the above one can't help you, 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.

amitchandak
Super User
Super User

@Hermarian , Create a new column in your table and use in visual

 New Qtr =if( [Year] < year(Today()) , [Year], [Qtr])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.