Forum Discussion

Sab's avatar
Sab
Icon for Helper V rankHelper V
4 years ago
Solved

Measure to count Reciprocal User Relationship

Hello all,   I have a dataset similar to the one shown below.   I need to create a measure that counts how many reciprocal relationships we have, so if a particular user sends a message to the re...
  • hnguy71's avatar
    hnguy71
    4 years ago

    Hi Sab ,

     

    That likely means your sender id is not unique and that it matches many purchase id.  Try this instead to return only the first value:

     

    TransmitEcho = 
    VAR _Receivers = VALUES('Table'[Receiver])
    RETURN
    IF(
        [Sender] in _Receivers, 
        VAR _ID = CALCULATE(MIN('Table'[ID]), FILTER('Table', 'Table'[Sender] = EARLIER('Table'[Receiver])), ALL('Table'[Receiver]))
        VAR _Key = 
            SWITCH( TRUE(), 
                ISBLANK(_ID), BLANK(),
                [ID] > _ID, COMBINEVALUES("^",_ID, [ID]),              
                COMBINEVALUES("^", [ID], _ID))
        RETURN
        _Key
    )

     

    If this doesn't work, if you can send some larger sample data for me to work with and I can test.

  • Ashish_Mathur's avatar
    4 years ago

    Hi,

    Create this calculated column formula

    Is this combination available elsewhere?=CALCULATE(COUNTROWS(Data),FILTER(data,Data[SenderID]=EARLIER(Data[ReceiverID])&&Data[ReceiverID]=EARLIER(Data[SenderID])))

    Write this measure and drag it to a card visual

    Measure = calculate(countrows(Data),Data[Is this combination available elsewhere?]=1)/2

    This will work only as long as a Send and Receiver ID pair appears twice only.