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

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. 

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

Hello @Anonymous 

 

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

 

 

Basically, you build the model model:

 

Capture1.PNGCapture2.PNG

 

and then add this measure:

 

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

 

Capture3.PNGCapture4.PNG

Please see the file I uploaded for more info. 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

2 REPLIES 2
LivioLanzo
Solution Sage
Solution Sage

Hello @Anonymous 

 

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

 

 

Basically, you build the model model:

 

Capture1.PNGCapture2.PNG

 

and then add this measure:

 

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

 

Capture3.PNGCapture4.PNG

Please see the file I uploaded for more info. 

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

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. 

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.