Forum Discussion

alepagg's avatar
alepagg
Frequent Visitor
2 years ago
Solved

Need to compare multiple rows in the same table

Hello,

I need help with this problem. I have a table like this:
BRAND | CUSTOMER | VALUE
A | X | 1

A | Y | 1

B | X | 2

B | Y | 0

C | X | 1

C | Y | 1

C | Z | 0

 

Brand is a slicer in my page. Based on the combination of brands the user selects, I need to return a table which shows only the customer with a positive value (>0) for each and every selected Brand.

For example, if A & B are selected, the result should be:
CUSTOMER | VALUE

X | 3

 

While if A & C are selected:
X | 2
Y | 2

 

Eventually, I need to create measures to count the number of customers active in multiple brands, and the total value they generate.

 

Thank you,

alepagg

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi alepagg ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

    Flag = 
    var _table=CALCULATETABLE(VALUES('Table'[CUSTOMER]),'Table'[VALUE]<=0)
    RETURN IF( not MAX('Table'[CUSTOMER]) in _table,1,0)

    (3) Place [Flag=1] on the visual object screening and then the result is as follows.

    Best Regards,

    Neeko Tang

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

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi alepagg ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

    Flag = 
    var _table=CALCULATETABLE(VALUES('Table'[CUSTOMER]),'Table'[VALUE]<=0)
    RETURN IF( not MAX('Table'[CUSTOMER]) in _table,1,0)

    (3) Place [Flag=1] on the visual object screening and then the result is as follows.

    Best Regards,

    Neeko Tang

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

    • alepagg's avatar
      alepagg
      Frequent Visitor

      Hi Neeko,

      Thanks a lot for your help! Your solution does work!

      However, my real scenario is quite complex and it's hard to replicate your proposal to my dashboard. Maybe you know how to use the Flag to calculate a measure
      - the number of Customers active in multiple Brands
      - the total value generated by the above Customers

      Thank you,

      Alessandro

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hi,

    Here is one way to do this:

    Create the following measure:

    Filter for above 0 = IF(MAX('Table (24)'[Value])>0,1,0)


    Place is as a filter like this:

     

    Now the slicer works as you described:

     

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/

    • alepagg's avatar
      alepagg
      Frequent Visitor

      Hi Valtteri,

      thanks for your prompt reply but I think it doesn't fully cover my need.

      Back to my example, when the user selects both A & B brands, the only customer that shows positive value for both brands is X. Therefore, the outcome measure or table should be only:
      X | 3
      While customer Y should be excluded since it is positive for brand A but not positive for brand B.