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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
genashpuryk
Helper I
Helper I

INDEX function issue

Good afternoon, everyone! 

I'm working on a school project and have a basic task, which turned out very difficult to solve. I have two tables: Sales table (top one) and Shops table used as mapping (below one). There is an active many-to-one relation between them which worked fine up until this task.

genashpuryk_0-1744962393599.png

The task is to calculate sales deficit from best-selling shop using INDEX function (divide total sales by total sales of the best-selling shop) in a matrix visual. Here is what I got:

genashpuryk_1-1744962774103.png

In this matrix, rows are hierarchy of cities/shops, column 1 is sum of sales and measure 1 is me trying to calculate the best selling shop. As far as I understand, measure1 should return "Магазин №8" since it's sales are the best. Instead, it just returns "Магазин №1, because it's alphabetically first. What am I doing wrong? This is a measure used:

measure1 =
    INDEX(1,ALLSELECTED('рПродажіФакт'[Магазин]),ORDERBY(SUM('рПродажіФакт'[Сума])))

Thanks everyone for your help.

1 ACCEPTED SOLUTION

Please provide sample data that fully covers your issue, in a usable format (no screenshot).
Please show the expected outcome based on the sample data you provided.

View solution in original post

9 REPLIES 9
alena2k
Resolver IV
Resolver IV

hi there! In addition to the order by direction you need to re-define the contest for SUM() using CALCULATE:

measure = INDEX(1, ALLSELECTED('Table'[store]),
                   ORDERBY(CALCULATE(SUM('Table'[sold]), REMOVEFILTERS('Table'[city])), DESC))

hi! thank you! unfortunately, that didn't really help 😞 
here is what i got using your solution, looks same to me. what can be the source of the problem?

genashpuryk_0-1745008672250.png

 

Please provide sample data that fully covers your issue, in a usable format (no screenshot).
Please show the expected outcome based on the sample data you provided.

Anonymous
Not applicable

Hi @genashpuryk,

 

As suggested bu super user can you please provide sample data that covers your issue with expected output, it will be helpful for us to address your issue more effectively.

 

Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @genashpuryk,

 

May I ask if you have gotten this issue resolved?

If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.


Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @genashpuryk,

 

May I ask if you have gotten this issue resolved?

If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.


Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @genashpuryk,

 

May I ask if you have gotten this issue resolved?

If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.


Regards,
Vinay Pabbu

Anonymous
Not applicable

Hi @genashpuryk,

 

As we haven't heard back from you, At this time we are closing this thread. If you have any further issues, please start a new thread in the community forum, and we are here to assist you. Thankyou for your understanding and continuous support.

Thank you for being part of the Microsoft Fabric Community.

 

Regards,

Vinay Pabbu

lbendlin
Super User
Super User

You need to specify that you want to order DESC.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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