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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
jomavero
New Member

RANKX not updating table values when filtering

Have a very simple PBI providing me some ranking sales.

I want the user to be able to choose year/category to get an updated ranking position JUST FOR SELECTED VENDORS.

The issue is: when filtering for a given number of vendors the RANKX is not updating the position as expected by DAX formula. (This should be 1 and 2 in the picture when selecting category: food and year: 2022)

jomavero_0-1706701289723.png

DAX:

POSITION = RANKX(FILTER(sales, sales[vendor] = SELECTEDVALUE(sales[vendor]) && sales[category] = SELECTEDVALUE(sales[category]) && sales[year] = SELECTEDVALUE(sales[year])), sales[rank])
jomavero_1-1706701305286.png

 

3 REPLIES 3
123abc
Community Champion
Community Champion

It seems like you're encountering an issue where the RANKX function isn't updating the position as expected when filtering for specific vendors, categories, and years in Power BI.

The DAX formula you provided looks correct at first glance. However, there could be several reasons why it's not behaving as expected:

  1. Relationships: Ensure that the relationships between your tables are correctly defined. If the relationships are not properly set up, the filtering might not work as intended.

  2. Data Model Filtering: Check if there are any filters applied at the report level or page level that could interfere with the expected results.

  3. Context Transition: RANKX is a function that performs context transition. Ensure that the context transition is happening correctly and that the filters are being applied in the right context.

  4. Data Model Integrity: Ensure that your data model is correct and that there are no data integrity issues causing unexpected results.

Here are some steps you can take to troubleshoot the issue:

  • Check the data model to ensure that the relationships are correctly defined.
  • Verify that there are no conflicting filters applied at different levels.
  • Test the DAX expression with simplified filters to see if it produces the expected results.
  • Double-check the data to ensure that it matches the criteria specified in your DAX expression.

If you've confirmed that your DAX expression is correct and the data model is set up properly, but you're still encountering issues, you may need to provide more information about your data model and the specific problem you're encountering for further assistance.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

There are no relationships, there are no other filters. The data is the table you see. Nothing else

123abc
Community Champion
Community Champion

Thank you for providing additional context. Based on the information you've provided, it seems the issue lies within the way RANKX is computing the rank position within your filter context. Since there are no relationships involved and you're applying filters directly within the RANKX function, there might be some nuances to consider.

Here are some potential troubleshooting steps you can take:

  1. Check Data Types: Ensure that the data types of the columns you're filtering on (vendor, category, year) match exactly with the values you're using in the SELECTEDVALUE function. Even minor differences can cause the filter to fail.

  2. Inspect Filter Context: Use DAX functions like CALCULATE and VALUES to inspect the filter context applied to the RANKX calculation. This can help you understand how the filters are being applied and whether they're affecting the calculation as intended.

  3. Test the Filter Conditions: To isolate the issue, try testing the filter conditions separately to see if they produce the expected results. You can create measures or calculated columns that count the number of rows that match each filter condition.

  4. Consider Row Context: Ensure that the RANKX function is iterating over the correct rows and considering the appropriate context when evaluating each row. In your case, it seems the issue might be related to how RANKX is handling the filter context within your formula.

  5. Check for Errors: Double-check for any errors in your DAX formula or potential conflicts with other measures or calculated columns that might affect the filter context.

  6. Simplify the Formula: Sometimes complex DAX formulas can lead to unexpected behavior. Try simplifying the formula or breaking it down into smaller parts to better understand how each component is contributing to the final result.

By following these steps and carefully examining your DAX formula and filter conditions, you should be able to identify the source of the issue and make any necessary adjustments to ensure the RANKX function behaves as expected within your Power BI report.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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