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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
AkashGhinmine
New Member

Power BI | Dynamic Sorting Based on User Selection

Hi Everyone! 

I have a task in Power BI and needed your help on dynamic sorting. 


I have the below table in my power bi report - 

 

AkashGhinmine_0-1731949810964.png

 

And I have created the below matrix visual to show details about Tender Forecasts.

 

AkashGhinmine_0-1732000592788.png


I used the below DAX to create a Forecast Table first to unpivot the dates - 

Foreacst =
UNION(
    SELECTCOLUMNS(
        Tenders,
        "Tender Name", Tenders[Tender Name],
        "Tender Forecast Type", "ITT",
        "Forecast Date", Tenders[ITE Forecast Date]
    ),
    SELECTCOLUMNS(
        Tenders,
        "Tender Name", Tenders[Tender Name],
        "Tender Forecast Type", "PQQ",
        "Forecast Date", Tenders[PQQ Forecast Date]
    )
)

 

AkashGhinmine_1-1732000717630.png

 

And created a measure to concatenate the Forecast Types - 

Concatenated Forecast Type = CONCATENATEX(Foreacst, Foreacst[Tender Forecast Type], " / ")

 

I wish to give the report users to have flexibility to select by which date field they want to sort the [Tender Name] by. The idea is to give a slicer or button in the report so that when the user selects the option (Sort By ITT or Sort by PQQ) the Tender Names are sorted by the selected field.

 

Do you think it is possible to achieve? If yes, could you please provide a solution or idea to approach this problem?

Note - I do not wish to add a new field in the table visual.

 

Thanks,

Akash

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @AkashGhinmine 

 

You can try to create two tables to store [Tender Name] and the rankings based on two different date columns, and use field parameters to switch the sorting.

1. Create two tables using the following DAX:

ITT_TenderRanks = 
ADDCOLUMNS(
    DISTINCT('Table'[Tender Name]),
    "ITT Rank", RANKX(ALL('Table'), CALCULATE(MAX('Table'[ITE Forecast Date])), , ASC, Dense)
)
PQQ_TenderRanks = 
ADDCOLUMNS(
    DISTINCT('Table'[Tender Name]),
    "PQQ Rank", RANKX(ALL('Table'), CALCULATE(MAX('Table'[PQQ Forecast Date])), , ASC, Dense)
)

2. Set the [Tender Name] column in both tables to be sorted by the ranked column:

vxianjtanmsft_0-1732081171163.pngvxianjtanmsft_1-1732081314952.png

3. Create a one-to-many unidirectional relationship between these two tables and the Forecast table:

vxianjtanmsft_3-1732081738646.png

4. Select the [Tender Name] field in both tables to create the field parameter:

vxianjtanmsft_2-1732081548235.png

5. Create a slicer with the field parameter and replace the [Tender Name] field with the field parameter in the matrix visual.

vxianjtanmsft_4-1732081942121.pngvxianjtanmsft_5-1732081975042.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @AkashGhinmine 

 

Please try the following steps:

1. Create a new table to store the sorting options

SortOptions = DATATABLE(
    "Sort By", STRING,
    {
        {"Sort By ITT"},
        {"Sort By PQQ"}
    }
)

2. Use the SortOptions[Sort By] field to create the slicer and check the "Single select" option in the slicer settings.

vxianjtanmsft_0-1731994955218.png

3. Create a measure that applies different date columns to be sorted based on the slicer selection.

SortOrder = 
VAR ITT = MAX('Table'[ITE Forecast Date])
VAR PQQ = MAX('Table'[PQQ Forecast Date])
VAR Selection = SELECTEDVALUE(SortOptions[Sort By])
RETURN
IF(Selection = "Sort By ITT", ITT, PQQ)

4. Create a table visual and drag Table[Tender Name] and the measure SortOrder into it.

vxianjtanmsft_1-1731995103881.pngvxianjtanmsft_2-1731995134471.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @Anonymous ,

 

hanks for your solution, but this does not work for the specific solution we are trying to build. I have updated the question to best explain what we wih to achieve. Could you please re-check the question and provide your inputs if we can achieve the same. 

The problem here is that I wish to sort specific column Tender Name dynamically due to the matrix visual and I dont want to add dates in that matrix visual as we already have date in it.

Thanks,

Akash

Anonymous
Not applicable

Hi @AkashGhinmine 

 

You can try to create two tables to store [Tender Name] and the rankings based on two different date columns, and use field parameters to switch the sorting.

1. Create two tables using the following DAX:

ITT_TenderRanks = 
ADDCOLUMNS(
    DISTINCT('Table'[Tender Name]),
    "ITT Rank", RANKX(ALL('Table'), CALCULATE(MAX('Table'[ITE Forecast Date])), , ASC, Dense)
)
PQQ_TenderRanks = 
ADDCOLUMNS(
    DISTINCT('Table'[Tender Name]),
    "PQQ Rank", RANKX(ALL('Table'), CALCULATE(MAX('Table'[PQQ Forecast Date])), , ASC, Dense)
)

2. Set the [Tender Name] column in both tables to be sorted by the ranked column:

vxianjtanmsft_0-1732081171163.pngvxianjtanmsft_1-1732081314952.png

3. Create a one-to-many unidirectional relationship between these two tables and the Forecast table:

vxianjtanmsft_3-1732081738646.png

4. Select the [Tender Name] field in both tables to create the field parameter:

vxianjtanmsft_2-1732081548235.png

5. Create a slicer with the field parameter and replace the [Tender Name] field with the field parameter in the matrix visual.

vxianjtanmsft_4-1732081942121.pngvxianjtanmsft_5-1732081975042.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

mh2587
Super User
Super User

You can achieve this using bookmarks and button combination


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Hey @mh2587 , 

Apologies for my mistake, I gave the wrong visual Screenshot. Unfortunately, I don't think bookmarks would work in this case becausse those date fields will not be a part of the visual. The idea would be to sort specific column [Tender Name] by the dates dynamically. I assume bookmarks would work only when we have those fields present in the visual.


 

Thanks,

Akash

NehaIngale_1111
New Member

I am stuck with similar situation, can anyone please provide solution

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors