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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
AnnaKi
Frequent Visitor

Sorting of sales in visual (matrix table) by specific year

Hi!

I have a table matrix visual with Sales per customer and Year. My Rows are customer, Columns Year and Values Sales.

 

 I want the customers to be sorted by Sales, this is no problem, the problem is that I want to sort customers by ONLY the sales in the specific  year of 2021. How can this be achieved?

 

AnnaKi_0-1635886520466.png

 

Thanks,

7 REPLIES 7
v-kelly-msft
Community Support
Community Support

Hi  @AnnaKi ,

 

Create 2 columns in your table:

rank = if('Table'[Year]=2021,RANKX(FILTER('Table','Table'[Year]=2021),'Table'[Value],,DESC,Dense))
Column = IF('Table'[rank]=BLANK(),CALCULATE(MAX('Table'[rank]),FILTER('Table','Table'[Customer]=EARLIER('Table'[Customer]))),'Table'[rank])

Then copy customer column and make it sort by Column,and you will see:

vkellymsft_0-1636094375447.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

Thanks, at the moment my measure can't find the field'Table'[Year] at the beginning of the IF(-statement If('Table'[Year] for some reason (In my model it is called 'DimDate'[Year]). But if I get the model to find it maybe it will work....

Hi @AnnaKi ,

 

Is your issue solved?

 

Best Regards,
Kelly

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

Hi  @AnnaKi ,

 

Measure cant do it,I was using calculated columns,and it needs to be done in the fact table.

 

Check my .pbix file for details.

 

Best Regards,
Kelly

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

Hi!

Thank you so much for your help. I can't get it to work though.

[Year] is in my 'DimDate' table (Calendar) and [Revenue] is in my fact table 'Transactions'.

 

If I add it in my 'Transactions' (fact) table I get this:

AnnaKi_1-1636624510239.png

 

If I add a rank column in 'DimDate' table I get this:

AnnaKi_2-1636624558369.png

 

Thanks again 🙂

 

 

TomMartens
Super User
Super User

Hey @AnnaKi ,

 

this article explains how you can sort a table visual using multiple columns, of course you can use a simple on the column header to sort by the last year: https://www.c-sharpcorner.com/article/how-to-sort-a-table-using-multiple-columns-in-power-bi/

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Sorry! I forgot to say it was a matrix table so I could't do that.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.