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
Anonymous
Not applicable

Displaying the data Year over Year in Matrix

I  wanted to display the data in Matrix table Year over Year:

 

sample out put of the report should look like as below.

Previous Year Week vs Current year week4/5/20194/6/20204/12/20194/13/20204/19/20194/20/20204/26/20194/27/2020April 2019April 2020Trend
Units1219242222121314   
            
            
6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous,

You can extract your data values and add a custom index column to setting custom sort order or date fields. Then you can link to the original table and use new table fields on matrix to enable custom sort order:

Custom Sorting in Power BI  

If you confuse about these steps, please share some dummy data to test.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

I tried this option,but didnt work. Can you please create a sample PBI file based on some sample data. Like

 

Units : Date: 

12       01/01/2019

13       01/02/2019

15       01/03/219

so on    until 12/31/2020

 

Anonymous
Not applicable

HI @Anonymous,

The sorting table should be ranked based on month and year part, you can consider using isonorafter function to achieve your requirement:

Sort = 
SUMMARIZE (
    ALL ( 'Table' ),
    [Date],
    "Index", COUNTROWS (
        FILTER (
            ALL ( 'Table' ),
            ISONORAFTER (
                    MONTH ( [Date] ), MONTH ( EARLIER ( 'Table'[Date] ) ), DESC,
                    YEAR ( [Date] ), YEAR ( EARLIER ( 'Table'[Date] ) ), DESC
            )
        )
    )
)

16.png

I also attached the sample file below, you can check it if it helps.

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Perfect ,this logic is working fine .thanks a lot.

 

Trying to display sum value as well at the of the matrix report like 2019 vs 2020 total sales at the end of the row.How to embed this logic into current one?

 

Image.png

 

 

Anonymous
Not applicable

Hi @Anonymous,

You can try to use below formula to append year to sort table.

Sort = 
VAR summary =
    SUMMARIZE (
        ALL ( 'Table' ),
        [Date],
        "Index", COUNTROWS (
            FILTER (
                ALL ( 'Table' ),
                ISONORAFTER (
                        MONTH ( [Date] ), MONTH ( EARLIER ( 'Table'[Date] ) ), DESC,
                        YEAR ( [Date] ), YEAR ( EARLIER ( 'Table'[Date] ) ), DESC
                )
            )
        )
    )
VAR yearList =
    ADDCOLUMNS (
        DISTINCT ( SELECTCOLUMNS ( summary, "Date", YEAR ( [Date] ) ) ),
        "Index",
        VAR offset =
            MINX ( summary, YEAR ( [Date] ) )
        VAR maxindex =
            MAXX ( summary, [Index] )
        RETURN
            [Date] - offset + maxindex + 1
    )
RETURN
    UNION (
        SELECTCOLUMNS ( summary, "Date", FORMAT(  [Date],"mm/dd/yyyy" ), "Index", [Index] ),
        yearList
    )

Notice: sort table existed both date type and number type values, so its date field can only be configured as text format.
For this scenario, you need to write a measure formula to use current category label to find out the corresponding value and use to replace the original value field and use on matrix visual.

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

Thanks a lot. I was trying to ammendent the sort formula ,but didn't work out for me.

 

Trying to understand below formula how does it help. What you mean by creating by another measure? Can you please help here.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors