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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Has no Results when Apply Slicer in USERELATIOSHIP Measure

Dear,

 

I have two tables, Clients and transactions, the table clients has Two RelationShips with table Transactions, one active and other inactive.

 

I have two types of clients, MasterClients and SubordinatesClients.... The subordinatesclients belongs with a masterclients, so, i need to show all subordinatesclients Values to a especific masterclient.

 

When an apply the slicer with the masterclient name, no subordinateclients appear.

 

My measure:

CALCULATE(SUM(TransactionsSubordinates[SubordinateNetAmount]);
USERELATIONSHIP(merchants[Id];TransactionsSubordinates[SubordinateMerchantId]))
 
In merchant table i have to types of merchants, the master and subordinates, i create a table only with masters merchants, when i apply a filter on the table, the list of subordinates values dont appear.
PowerBiProblem.PNG
1 ACCEPTED SOLUTION
technolog
Super User
Super User

In Power BI, when working with multiple relationships between two tables, it's essential to ensure that the correct relationship is being used in each context. If you have one active and one inactive relationship, you would typically use the active relationship for most visuals and measures. For measures that need to use the inactive relationship, you would leverage the USERELATIONSHIP function within the CALCULATE function to activate that relationship for the context of the calculation.

 

Based on your description, it seems that the slicer you're using is filtering the master clients, but the measure is not reflecting the subordinate clients as expected. Here are a few steps to troubleshoot and resolve this issue:

  1. Ensure Correct Relationships: Double-check that the inactive relationship is correctly set up between the merchants[Id] and TransactionsSubordinates[SubordinateMerchantId].
  2. Use Correct Slicer: Make sure that the slicer you're using is based on the master clients' list. It should be connected to the merchants table where master clients' IDs are stored.
  3. Review Filter Context: Remember that slicers affect the filter context. Your measure will only calculate values for the SubordinateNetAmount where the SubordinateMerchantId matches the Id from the merchants table currently selected by the slicer.
  4. Inactive Relationship Usage: The USERELATIONSHIP function is used correctly to activate the inactive relationship for the calculation. However, you should make sure that the inactive relationship does not get overridden by any other filter in the report.
  5. Review Calculation: If you want to show all subordinate client values for a specific master client, ensure that your measure is not being filtered out or overridden by another measure or filter in the report.

Here is a revised version of the measure that you might want to consider:

 

SubordinateNetAmountForMaster = CALCULATE( SUM(TransactionsSubordinates[SubordinateNetAmount]), USERELATIONSHIP(merchants[MasterClientId], TransactionsSubordinates[MasterMerchantId]) )

 

In this revised measure, replace merchants[MasterClientId] with the appropriate column that identifies master clients in your merchants table and TransactionsSubordinates[MasterMerchantId] with the column in TransactionsSubordinates that corresponds to the master clients. The measure assumes that MasterClientId and MasterMerchantId are the columns used to establish the relationship between the two tables for master clients.

If this does not resolve the issue, it's possible that there are other factors at play, such as additional filters in your report or issues with the data model that might be preventing the expected results from displaying. You might want to inspect any other measures or visuals that could be influencing the filter context and adjust accordingly.

View solution in original post

1 REPLY 1
technolog
Super User
Super User

In Power BI, when working with multiple relationships between two tables, it's essential to ensure that the correct relationship is being used in each context. If you have one active and one inactive relationship, you would typically use the active relationship for most visuals and measures. For measures that need to use the inactive relationship, you would leverage the USERELATIONSHIP function within the CALCULATE function to activate that relationship for the context of the calculation.

 

Based on your description, it seems that the slicer you're using is filtering the master clients, but the measure is not reflecting the subordinate clients as expected. Here are a few steps to troubleshoot and resolve this issue:

  1. Ensure Correct Relationships: Double-check that the inactive relationship is correctly set up between the merchants[Id] and TransactionsSubordinates[SubordinateMerchantId].
  2. Use Correct Slicer: Make sure that the slicer you're using is based on the master clients' list. It should be connected to the merchants table where master clients' IDs are stored.
  3. Review Filter Context: Remember that slicers affect the filter context. Your measure will only calculate values for the SubordinateNetAmount where the SubordinateMerchantId matches the Id from the merchants table currently selected by the slicer.
  4. Inactive Relationship Usage: The USERELATIONSHIP function is used correctly to activate the inactive relationship for the calculation. However, you should make sure that the inactive relationship does not get overridden by any other filter in the report.
  5. Review Calculation: If you want to show all subordinate client values for a specific master client, ensure that your measure is not being filtered out or overridden by another measure or filter in the report.

Here is a revised version of the measure that you might want to consider:

 

SubordinateNetAmountForMaster = CALCULATE( SUM(TransactionsSubordinates[SubordinateNetAmount]), USERELATIONSHIP(merchants[MasterClientId], TransactionsSubordinates[MasterMerchantId]) )

 

In this revised measure, replace merchants[MasterClientId] with the appropriate column that identifies master clients in your merchants table and TransactionsSubordinates[MasterMerchantId] with the column in TransactionsSubordinates that corresponds to the master clients. The measure assumes that MasterClientId and MasterMerchantId are the columns used to establish the relationship between the two tables for master clients.

If this does not resolve the issue, it's possible that there are other factors at play, such as additional filters in your report or issues with the data model that might be preventing the expected results from displaying. You might want to inspect any other measures or visuals that could be influencing the filter context and adjust accordingly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors