Forum Discussion

Cling's avatar
Cling
Frequent Visitor
1 year ago

Measure problem with USERELATIONSHIP

Hi!

 

This is my Power BI Model, a simplify version:

 

I have a selector based on PERCENTAGE TABLE[PERCENTAGE] which objective is to filter on the % FILTERED measure defined as

 

% FILTERED =
IF( ISFILTERED('PRODUCT'[PART] )|| ISFILTERED('PART'[PART]),
CALCULATE([%_PART], USERELATIONSHIP( 'PERCENTAGE TABLE'[PERCENTAGE], 'PRODUCT'[PART_PERCENTAGE])),
[%_PRODUCT]).
 
Where, 
%_PART = CALCULATE(AVERAGE('PRODUCT'[PART_PERCENTAGE])) and 
%_PRODUCT = CALCULATE (AVERAGE('PRODUCT'[PRODUCT_PERCENTAGE]))
 
The idea is that if we are at part level, the %_part measure is displayed and filtered, while if we are not at part level, the % product measure is displayed and filtered. The problem is that if in a table visual, if we include the following measure, the filter applied by the selector does not work correctly, and % filtered shows in blank. Example:
 
TOTAL = VAR result = CALCULATE (
        SUM( 'PRODUCT'[WEIGHT] )
    )
RETURN
    IF (result = 0, BLANK (), result)
 
Selecting total measure:

 

Without total measure and the expected result:

 

Please, anyone could help me with this problem?

 

Thanks in advance.

 

4 Replies

  • Cling 

    You can try modifying the % FILTERED measure to ensure that the filter context is correctly applied. Here is a revised version of your measure:

    DAX
    % FILTERED =
    IF(
    ISFILTERED('PRODUCT'[PART]) || ISFILTERED('PART'[PART]),
    CALCULATE(
    [%_PART],
    USERELATIONSHIP('PERCENTAGE TABLE'[PERCENTAGE], 'PRODUCT'[PART_PERCENTAGE])
    ),
    CALCULATE(

     

    • Cling's avatar
      Cling
      Frequent Visitor

      Doesn´t work, sorry.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Cling 

     

    May I ask if you have gotten this issue resolved? If it is solved, please 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.

     

    If it hasn't been resolved yet, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Cling's avatar
      Cling
      Frequent Visitor

      The problem is not solved.