Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
RevOps608
Helper II
Helper II

Getting Sum of value based on one or both columns without duplicates

I need to get total sales (Total Sales ACV) from the Opportunity Table for Accounts in the Accounts table using two relationships to the same table without duplicating sums. The Acct Id can be the in the Acct ID column in the Opportunity Table, the CPA Acct in the Opportunity Table or both. I want to get the total sales without adding the sales twice if they're in both fields.

 

The two relationships are Account(AccountId) > Opportunity(AcctId) &

Account(AcctId) > Opportunity(CPA_Acct_Id). I've tried using Gregs formula from a previous question posted without any luck.

Measure = SUMX(SUMMARIZE(DistinctSum,[KEY],"Payment",AVERAGE(DistinctSum[PAYMENT])),[Payment])

 

 

acct opp tables.pngtable of opps.png

1 ACCEPTED SOLUTION
RevOps608
Helper II
Helper II

I was able to solve this. Greg's measure did end up working. I just had to get my table in proper format.

Measure = SUMX(
SUMMARIZE(
FILTER('2024 End Client CPA Calc Table',
'2024 End Client CPA Calc Table'[ACV Yr] = 2024),
'2024 End Client CPA Calc Table'[ Opp Id],
"ACV", AVERAGE('2024 End Client CPA Calc Table'[ACV])),
[ACV])

 

Summary table

VAR endclient24 =
SUMMARIZE(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank]),
Opportunity[Close_Year__c] = 2024
),
Opportunity[ Opp Id],
Opportunity[AccountId],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR cpaacct24 =
SUMMARIZE(
FILTER(
FILTER(
Opportunity,
Opportunity[CPA_Contact_Account__c] <> [Blank]),
Opportunity[Close_Year__c] = 2024
),
Opportunity[ Opp Id],
Opportunity[CPA_Contact_Account__c],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR endclient =
SUMMARIZE(
FILTER(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank] ),
Opportunity[Close_Year__c] = 2023 ),
Opportunity[Record_Type_Name__c (groups)] <> "ERC"
),
Opportunity[ Opp Id],
Opportunity[AccountId],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR cpaacct =
SUMMARIZE(
FILTER(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank] ),
Opportunity[Close_Year__c] = 2023 ),
Opportunity[Record_Type_Name__c (groups)] <> "ERC"
),
Opportunity[ Opp Id],
Opportunity[CPA_Contact_Account__c],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)

RETURN
UNION(
endclient24,
cpaacct24,
endclient,
cpaacct)

View solution in original post

3 REPLIES 3
RevOps608
Helper II
Helper II

I was able to solve this. Greg's measure did end up working. I just had to get my table in proper format.

Measure = SUMX(
SUMMARIZE(
FILTER('2024 End Client CPA Calc Table',
'2024 End Client CPA Calc Table'[ACV Yr] = 2024),
'2024 End Client CPA Calc Table'[ Opp Id],
"ACV", AVERAGE('2024 End Client CPA Calc Table'[ACV])),
[ACV])

 

Summary table

VAR endclient24 =
SUMMARIZE(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank]),
Opportunity[Close_Year__c] = 2024
),
Opportunity[ Opp Id],
Opportunity[AccountId],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR cpaacct24 =
SUMMARIZE(
FILTER(
FILTER(
Opportunity,
Opportunity[CPA_Contact_Account__c] <> [Blank]),
Opportunity[Close_Year__c] = 2024
),
Opportunity[ Opp Id],
Opportunity[CPA_Contact_Account__c],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR endclient =
SUMMARIZE(
FILTER(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank] ),
Opportunity[Close_Year__c] = 2023 ),
Opportunity[Record_Type_Name__c (groups)] <> "ERC"
),
Opportunity[ Opp Id],
Opportunity[AccountId],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)
VAR cpaacct =
SUMMARIZE(
FILTER(
FILTER(
FILTER(
Opportunity,
Opportunity[AccountId] <> [Blank] ),
Opportunity[Close_Year__c] = 2023 ),
Opportunity[Record_Type_Name__c (groups)] <> "ERC"
),
Opportunity[ Opp Id],
Opportunity[CPA_Contact_Account__c],
"ACV Yr", Opportunity[Opp Close Year],
"ACV", SUM(Opportunity[Total Sales ACV])
)

RETURN
UNION(
endclient24,
cpaacct24,
endclient,
cpaacct)

Samarth_18
Community Champion
Community Champion

Hi @RevOps608 ,

 

Please try the below code:-

Total Sales ACV = 
CALCULATE(
    SUM(Opportunity[SalesAmount]),
    UNION(
        FILTER(Opportunity, Opportunity[AcctId] IN VALUES(Accounts[AccountId])),
        FILTER(Opportunity, Opportunity[CPA_Acct_Id] IN VALUES(Accounts[AcctId]))
    )
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thank you for replying. Your measure is on the right in the values, 'End Client - CPA Acct Total Sales'. It's only returning sales from the 'Acct Id' field. The measure on the left in the matrix, ('Total Sales (ACV)' is a measure that sums sales from the 'Acct Id' field in the opportunity table. The middle measure '2024 Opp CPA Acct ACV' is the sum of sales from 'CPA Acct Id'.

Side note: The active relationship between the Account and Opportuntiy table is 'Acctont[Acct Id] > Opportunity[Acct Id]. There is an inactive relationship between Account[Acct Id] > Opportunity[CPA_Contact_acct] (aka cpa contact Id).

 

measure tested.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.