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
MattiaFratello
Super User
Super User

Matrix with Categorical Data to look live values

Hi everyone, 

 

Is it possible in Power BI or Report Builder to create a matrix as the following?

MattiaFratello_0-1741689263894.png

 

To have Category as columns and under each category a list of games (present in that category) ordered by GGR.

I believe no but maybe someone has find a solution.

 

Thanks in advance.

1 ACCEPTED SOLUTION

HI @MattiaFratello ,

 

Not sure if the setup is the same I have but you need something similar to this.

 

  • Create a table for the Matrix headers this should include the Categories names and a colum for Game and GRR

MFelix_0-1741795700414.png

  • Also create a parameter table with numeric range (in my case I created until 20 but it can be more.

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-what-if#create-a-parameter

 

Now add the following measure:

Matrix Values = 
        VAR _temptable = CALCULATETABLE(
			'Games Table',
			'Games Table'[Category] IN VALUES(Categories[Category])
		    )

		VAR _TopN = TOPN(
			[Order Value],
			_temptable,
			'Games Table'[GGR]
		    )

		RETURN
			IF(
				[Order Value] <= COUNTROWS(_temptable),
				SWITCH(
					SELECTEDVALUE('Categories'[Calculation]),
					"Game", MAXX(
						TOPN(
							1,
							_TopN
						),
						'Games Table'[Game Name]
					),
					"GRR", MAXX(
						TOPN(
							1,
							_TopN
						),
						'Games Table'[GGR]
					)
				)
			)

Now setup you matrix with the following way:

  • Rows:
    • Order
  • Columns
    • Category
    • Calculation
  • Values
    • Matrix Value

MFelix_1-1741795924387.png

 

Please see file attach.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

8 REPLIES 8
MFelix
Super User
Super User

Hi @MattiaFratello ,

 

You can have this type of matrix however there would be an additional row on the headers for each catory something similar to:

 

Category A Category B Category C
Game GGR Game GGR Game GGR
Game 1 GGR 1 Game 1 GGR 1 Game 1 GGR 1
Game 2 GGR 2 Game 2 GGR 2 Game 2 GGR 2

 

The only question I have is concerning what you present on the GGR you want all the games to be sorted based on the GGR?

 

So for category A the first game would be the one with the highest GGR and so on?

 

This can be achieve with some dax coding and an additional setup of the calculations.

 

If you confirm my conclusion on the sorting I can try and send you a example.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix, that's exactly what I need. 

Would be lovely to have an example. Thanks in advance!

HI @MattiaFratello ,

 

Not sure if the setup is the same I have but you need something similar to this.

 

  • Create a table for the Matrix headers this should include the Categories names and a colum for Game and GRR

MFelix_0-1741795700414.png

  • Also create a parameter table with numeric range (in my case I created until 20 but it can be more.

https://learn.microsoft.com/en-us/power-bi/transform-model/desktop-what-if#create-a-parameter

 

Now add the following measure:

Matrix Values = 
        VAR _temptable = CALCULATETABLE(
			'Games Table',
			'Games Table'[Category] IN VALUES(Categories[Category])
		    )

		VAR _TopN = TOPN(
			[Order Value],
			_temptable,
			'Games Table'[GGR]
		    )

		RETURN
			IF(
				[Order Value] <= COUNTROWS(_temptable),
				SWITCH(
					SELECTEDVALUE('Categories'[Calculation]),
					"Game", MAXX(
						TOPN(
							1,
							_TopN
						),
						'Games Table'[Game Name]
					),
					"GRR", MAXX(
						TOPN(
							1,
							_TopN
						),
						'Games Table'[GGR]
					)
				)
			)

Now setup you matrix with the following way:

  • Rows:
    • Order
  • Columns
    • Category
    • Calculation
  • Values
    • Matrix Value

MFelix_1-1741795924387.png

 

Please see file attach.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix, is there a way to let this work if I have a Fact Table with all my metrics, then two Dim Tables, one for Games and one for Categories (everything with relationship 1 -> n)

Fact n -> 1 Games 
Games n -> 1 Categories

 

 

Thanks in advance

Hi @MattiaFratello ,

 

Yes there is no problem you just need to replace the Categories and the Games on the DAX  measure by the columns on the dimension tables

 

Would be similar to this:

 

Matrix Values = 
        VAR _temptable = FILTER(
			ADDCOLUMNS('Fact Table',"Category", DimTable[Category], "Game", GameTable[Game]),
			[Category] IN VALUES(Categories[Category])
		    )

		VAR _TopN = TOPN(
			[Order Value],
			_temptable,
			'Fact Table'[GGR]
		    )

		RETURN
			IF(
				[Order Value] <= COUNTROWS(_temptable),
				SWITCH(
					SELECTEDVALUE('Categories'[Calculation]),
					"Game", MAXX(
						TOPN(
							1,
							_TopN
						),
						'[Game]
					),
					"GRR", MAXX(
						TOPN(
							1,
							_TopN
						),
						[GGR]
					)
				)
			)

Doing the changes on the fly so they may need some updates.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks a lot mate!

Hi @MFelix, I've updated your formula as follow, and it seems to work mostly fine:

 

Matrix Values = 
    VAR _temptable = FILTER(
        ADDCOLUMNS('Casino Detailed - Current', 
            "Category", RELATED('Game Categories'[Game Category]), 
            "Game", RELATED(Games[Game])
        ),
        [Category] IN VALUES(Categories[Game Category])
    )

    VAR _TopN = TOPN(
        [Order Value],
        _temptable,
        [GGR]
    )

    RETURN
        IF(
            [Order Value] <= COUNTROWS(_temptable),
            SWITCH(
                SELECTEDVALUE('Categories'[Calculation]),
                "Game", MAXX(
                    TOPN(
                        1,
                        _TopN
                    ),
                    [Game]  
                ),
                "GGR", MAXX(  
                    TOPN(
                        1,
                        _TopN
                    ),
                    [GGR]
                )
            )
        )
 
My only question is, I have several slicers such as Date, Operator, Provider.
It seems that they are duplicating some rows withing the Matrix.
 
Any ideas?
Thanks in advance

Hi @MattiaFratello ,

 

Can you please share a mockup data or sample of your PBIX file. You can use a onedrive, google drive, we transfer or similar link to upload your files.

If the information is sensitive please share it trough private message.


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors