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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sureshg2498
Advocate I
Advocate I

Matrix Visual cell value moving to front

Hi All,

 

We have a data table as shown below.

Raw Data- Table Name: Customers

IndexCountryFiscal QuarterCustomer NameHealth
1USAFY Q1 2024T Mobile Red
2USAFY Q1 2024J&J Green
3USAFY Q2 2024WallmartGreen

 

Created the Matrix visual with the Health slicer as shown below.

sureshg2498_1-1733746614129.png

 

DAX for "Custom Index" column:

Custom Index =
VAR CurrentCountry = 'Customers'[Country]
VAR CurrentQuarter = 'Customers'[Fiscal Quarter]
VAR CurrentIndex = 'Customers'[Index]
VAR SortedTable =
    FILTER (
        'Customers',
        'Customers'[Country] = CurrentCountry &&
        'Customers'[Fiscal Quarter] = CurrentQuarter
    )
RETURN
    RANKX(SortedTable, 'Customers'[Index], , ASC, Dense)

 

 

When I select the Slicer value 'Green' the report will display as shown below.

sureshg2498_2-1733746857700.png

 

But our expected results would be as shown below. In a single row.

 

sureshg2498_4-1733747204247.png

 

Would it be possible to get the visual as shown above.

Could anyone please help me on this?

 

 

Thanks,

Suresh.

 

@Bibiano_Geraldo @rajendraongole1 @Ritaf1983 @danextian

 

1 ACCEPTED SOLUTION

Here is the sample .pbix file, use the link to see the solution:
TestFile.pbix


Output:

SShaikh_0-1733860659134.pngSShaikh_1-1733860681882.pngSShaikh_2-1733860698795.png

Tips:
In third matrix table added custom index column and make the matrix layout tabular

SShaikh_3-1733860867922.png

Rename the custom index colum with blank character

SShaikh_4-1733860935741.png

make the +/- icon option off

SShaikh_6-1733861144680.png

and reduce the width of the column to make the value diappear

SShaikh_5-1733861054405.png

hope this trick will solve your problem.

View solution in original post

13 REPLIES 13
Bibiano_Geraldo
Super User
Super User

Hi @sureshg2498 ,
In your Rankx, just rank by health as shown bellow:

Custom Index = 
VAR CurrentCountry = 'Customers'[Country]
VAR CurrentQuarter = 'Customers'[Fiscal Quarter]
VAR CurrentIndex = 'Customers'[Index]
VAR SortedTable =
    FILTER (
        'Customers',
        'Customers'[Country] = CurrentCountry &&
        'Customers'[Fiscal Quarter] = CurrentQuarter
    )
RETURN
    RANKX(SortedTable, 'Customers'[Health], , ASC, Dense)


By default, your Matrix will look like this:

Bibiano_Geraldo_0-1733835712574.png

 

Thank you so much for your reply, Bibiano.

I did exactly what you said. But i see only one row. Could you please help me ?

sureshg2498_1-1733839485397.png

sureshg2498_2-1733839604866.png

 

Thanks,

Suresh.

 

To be more accurate, please can you share a sample file? Make sure to not share sensitive information.

 

I didn't saw your file here on the post

Hi Bibiano - Thank you so much for your time.

Unfortunately, I do not have option to attach the pbix file. Below is the data that I have in the table.

Table: Customers

IndexCountryFiscal QuarterCustomer NameHealth
1USAFY Q1 2024T Mobile Green
2USAFY Q1 2024J&J Green
3USAFY Q2 2024WallmartRed

 

By Default the results:

sureshg2498_0-1733850738723.png

 

For Green selection: Client is expecting the results as shown below.

 

sureshg2498_1-1733850862675.png

For Red:

sureshg2498_2-1733850920251.png

 

If you have the solution, kindly attach the pbix file.

 

Thank you so much for help and support. Much appreciated.

 

 

 

 

Thanks,

Suresh.

 

 

 

 

Here is the sample .pbix file, use the link to see the solution:
TestFile.pbix


Output:

SShaikh_0-1733860659134.pngSShaikh_1-1733860681882.pngSShaikh_2-1733860698795.png

Tips:
In third matrix table added custom index column and make the matrix layout tabular

SShaikh_3-1733860867922.png

Rename the custom index colum with blank character

SShaikh_4-1733860935741.png

make the +/- icon option off

SShaikh_6-1733861144680.png

and reduce the width of the column to make the value diappear

SShaikh_5-1733861054405.png

hope this trick will solve your problem.

I sincerely apologise for disturbing you. The same logic/Trick is not working for the below dataset. Could you please help me on it.

 

IndexCountryFiscal QuarterCustomer NameHealth
1USAFY Q1 2024T Mobile Green
2USAFY Q1 2024J&J Green
3USAFY Q2 2024WallmartRed

This file has data sets with different variations, hope this could help you to get desired result,

TestFile2.pbix

And you could play with the order in Rankx function for your desired output( change the order to DESC )

Custom Index 1 = 
VAR CurrentCountry ='Data 1'[Country]
VAR CurrentQuarter ='Data 1'[Fiscal Quarter]
VAR CurrentIndex ='Data 1'[Index]
VAR SortedTable =
    FILTER (
       'Data 1',
       'Data 1'[Country] = CurrentCountry &&
       'Data 1'[Fiscal Quarter] = CurrentQuarter
    )
RETURN
    //RANKX(SortedTable,'Data 1'[Health], , ASC, Dense)
    RANKX(SortedTable,'Data 1'[Index], , DESC, Dense)

Or order it based on Index and Health both the columns (below code needs a calculated column -

Health Priority = IF('Data 1'[Health]="Green",1,2))

Custom Index 2 = 
VAR CurrentCountry = 'data 1'[Country]
VAR CurrentQuarter = 'data 1'[Fiscal Quarter]
VAR CurrentIndex = 'data 1'[Index]
VAR SortedTable =
    FILTER(
        'data 1',
        'data 1'[Country] = CurrentCountry &&
        'data 1'[Fiscal Quarter] = CurrentQuarter
    )
RETURN
     RANKX(SortedTable,'Data 1'[Health Priority] * 10000 + 'data 1'[Index], , ASC, Dense)



Thank you so much Shaikh. Much appreciated.

 

Hi, to share you need to upload the file to the cloud like onedrive or other, and share the link for download here in comments. 

lbendlin
Super User
Super User

Only if you remove the "Custom Index"  field from the rows, and modify your measure.

Thank you so much Ibendlin fo your reply.

Could you please let me know what chnges needs to be done to the measure ?

Implicitly via First Customer and First Health  (taking advantage of the fact that Green sorts before Red)

 

lbendlin_0-1733772279771.png

 

Thank you for the reply Ibendlin.

I have removed the custom index from the visual.

 

sureshg2498_0-1733804887660.png

However, I could not see the Red health record as shown below without any slicer value. selection.

sureshg2498_1-1733804957764.png

I'm new to Power BI development. Would it be possible to attach the Pbix file for the reference.

 

 

Thanks,

Suresh.

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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