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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Hide certain parts of matrix

Good afternoon.

I have the following matrix

 

 

cquiros_3-1632775839331.png

 

 But , i want in the following form:

 

Type201920202021Chg ABSChg %
A-Revenue16,352,23319,912,52622,275,2532,362,72711.9%
B-Cost of Sales-697,902-931,800-1,637,882-706,08275.8%
C-GP15,654,33118,980,72620,637,3711,656,6458.7%
D-Does-12,123,759-14,666,690-15,194,498-527,8083.6%
E-OP3,530,5724,314,0365,442,8731,128,83726.2%

 

It's possible?

Also, I don't understand how to make the matrix calculate the Subtotal correctly. The Chg ABS=22,275,253-19,912,526 and
Chg %= 2,362,727/19,912,526

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi  @Anonymous ,

Test the following measure:

 

Chg_ABS = 
CALCULATE (
    MAX ( 'Table'[value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Type] = MAX ( 'Table'[Type] )
            && 'Table'[Year] = MAX ( 'Table'[Year] )
    )
)
    - CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Type] = MAX ( 'Table'[Type] )
                && 'Table'[Year]
                    = MAX ( 'Table'[Year] ) - 1
        )
    )
Chg % = FORMAT(DIVIDE([Chg_ABS],CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Type]=MAX('Table'[Type])&&'Table'[Year]=MAX('Table'[Year])))),"0.001")*100&""&"%"

 

vluwangmsft_0-1632967402186.png

And if you want to show as your show ,test below:

Step1,create the following column:

Chg_ABS2 = IF('Table'[Year]=2021,
CALCULATE (
    MAX ( 'Table'[value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Type] = EARLIER( 'Table'[Type] )
            && 'Table'[Year] = EARLIER ( 'Table'[Year] )
    )
)
    - CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Type] = EARLIER ( 'Table'[Type] )
                && 'Table'[Year]
                    = EARLIER ( 'Table'[Year] ) - 1
        )
    ),BLANK())

 

Chg %2 = IF('Table'[Year]=2021,FORMAT(DIVIDE([Chg_ABS],CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Type]=EARLIER('Table'[Type])&&'Table'[Year]=EARLIER('Table'[Year])))),"0.001")*100&""&"%",BLANK())

 

Then create the following talbe:

Table3 = ADDCOLUMNS(SUMMARIZE('Table','Table'[Type],'Table'[Chg_ABS2]),"Year","Chg_ABS")
Table4 = ADDCOLUMNS(SUMMARIZE('Table','Table'[Type],'Table'[Chg %2]),"Year","Chg %")

merge table:

Table2 = UNION( SUMMARIZE('Table','Table'[Year],'Table'[Type],'Table'[value]), SELECTCOLUMNS(Table3,"Year",Table3[Year],"Type",Table3[Type],"value",Table3[Chg_ABS2]), SELECTCOLUMNS(Table4,"Year",Table4[Year],"Type",Table4[Type],"value",Table4[Chg %2]))

 

Create table base on the table2:

vluwangmsft_1-1632974164579.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi  @Anonymous ,

Test the following measure:

 

Chg_ABS = 
CALCULATE (
    MAX ( 'Table'[value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Type] = MAX ( 'Table'[Type] )
            && 'Table'[Year] = MAX ( 'Table'[Year] )
    )
)
    - CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Type] = MAX ( 'Table'[Type] )
                && 'Table'[Year]
                    = MAX ( 'Table'[Year] ) - 1
        )
    )
Chg % = FORMAT(DIVIDE([Chg_ABS],CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Type]=MAX('Table'[Type])&&'Table'[Year]=MAX('Table'[Year])))),"0.001")*100&""&"%"

 

vluwangmsft_0-1632967402186.png

And if you want to show as your show ,test below:

Step1,create the following column:

Chg_ABS2 = IF('Table'[Year]=2021,
CALCULATE (
    MAX ( 'Table'[value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Type] = EARLIER( 'Table'[Type] )
            && 'Table'[Year] = EARLIER ( 'Table'[Year] )
    )
)
    - CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Type] = EARLIER ( 'Table'[Type] )
                && 'Table'[Year]
                    = EARLIER ( 'Table'[Year] ) - 1
        )
    ),BLANK())

 

Chg %2 = IF('Table'[Year]=2021,FORMAT(DIVIDE([Chg_ABS],CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),'Table'[Type]=EARLIER('Table'[Type])&&'Table'[Year]=EARLIER('Table'[Year])))),"0.001")*100&""&"%",BLANK())

 

Then create the following talbe:

Table3 = ADDCOLUMNS(SUMMARIZE('Table','Table'[Type],'Table'[Chg_ABS2]),"Year","Chg_ABS")
Table4 = ADDCOLUMNS(SUMMARIZE('Table','Table'[Type],'Table'[Chg %2]),"Year","Chg %")

merge table:

Table2 = UNION( SUMMARIZE('Table','Table'[Year],'Table'[Type],'Table'[value]), SELECTCOLUMNS(Table3,"Year",Table3[Year],"Type",Table3[Type],"value",Table3[Chg_ABS2]), SELECTCOLUMNS(Table4,"Year",Table4[Year],"Type",Table4[Type],"value",Table4[Chg %2]))

 

Create table base on the table2:

vluwangmsft_1-1632974164579.png

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

Anonymous
Not applicable

Hi,  , thanks for your deeply appreciated help. It worked with some minor modifications.

Greg_Deckler
Super User
Super User

@Anonymous Yes it is possible: The New Hotness (Custom Matrix Hierarchy) - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!