Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Sum column based on value of another column, include filter context

Hello,

 

I currently have the following dataset:

Dataset     
AgentAgent (Pair)Pair IndexWeekSalesProduct
CoryCory 11-Feb1000A
AngelaAngela 11-Feb2000A
PamPam, Jim104-Feb3000A
JimJim, Pam111-Feb4000A
MichaelMichael, Tony204-Feb5000A
TonyTony, Michael204-Feb6000A
SamSam 11-Feb7000C

 

I want to create a table that

1) filters out Product C,

2) has the paired agents (the second column which is based on their pair index),

3) and the average of the sales of each pair (and if they're not a pair just their own sales). 

 

Desired Results 
Agent (Pair)Sales
Cory1000
Angela2000
Pam, Jim3500
Jim, Pam3500
Michael, Tony5500
Tony, Michael5500

 

In this scenario, when I filter on Feb 11, it would take out both Michael and Tony. Since Jim has made $4000 in this week, both "Jim, Pam" and "Pam, Jim" would be in this table with $2000 sales each ($4000/2). 

 

Desired Results for Feb 11
Agent (Pair)Sales
Cory1000
Angela2000
Pam, Jim2000
Jim, Pam2000

 

How would you go about creating a measure for the sales? I'm currently using a calculated column, but I cannot filter based on Week. 

 

Thank you so much for your time and I apologize for the complexity. 

  • Hello Anonymous 

     

    I have uploaded a pbix file for you here: https://1drv.ms/u/s!AiiWkkwHZChHj1_GgTacH8l6Qsxi

     

     

    Basically, you build the model model:

     

     

    and then add this measure:

     

    AvgSales = 
        SUMX(
            AgentsPairs,
            CALCULATE( 
                SUM( Sales[Sales] ),
                CROSSFILTER( AgentsPairs[Agent1], Agents[Agent], Both )
            ) * AgentsPairs[Ratio]
        )

     

    Please see the file I uploaded for more info. 

2 Replies

  • Hello Anonymous 

     

    I have uploaded a pbix file for you here: https://1drv.ms/u/s!AiiWkkwHZChHj1_GgTacH8l6Qsxi

     

     

    Basically, you build the model model:

     

     

    and then add this measure:

     

    AvgSales = 
        SUMX(
            AgentsPairs,
            CALCULATE( 
                SUM( Sales[Sales] ),
                CROSSFILTER( AgentsPairs[Agent1], Agents[Agent], Both )
            ) * AgentsPairs[Ratio]
        )

     

    Please see the file I uploaded for more info. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello, 


      Thank you so much! The original request was modified so I had to go a different route, but your solution would have fixed my issue.