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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jd8766
Helper II
Helper II

Calculate measure where sold user = user from related table?

Hi, I have a sales table and company table like the below.. I am trying to build a measure that counts the number of contractkeys per user... but only where the solduserkey is the same owneruserkey in the company table.

So for example, for contractkey 10, the solduserkey was 111 and the companykey was 736. On the company table, companykey 736 is "owned" by 111, so we would count this sale.

ContractKey 12 has a sold user key of 112 and a companykey of 222... but on the company table, companykey 222 is owned by owner user key 111 so this wouldn't count.

Does that make sense? What would the best way be to achieve this? (using SSAS tabular live connection)

jd8766_1-1658227719811.png

 



1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @jd8766 

 

You can try this measure

Count of Contracts =
VAR _companyKeys =
    CALCULATETABLE (
        VALUES ( Company[CompanyKey] ),
        FILTER ( Company, Company[OwnerUserKey] IN VALUES ( Sales[SoldUserKey] ) )
    )
RETURN
    COUNTX (
        FILTER ( Sales, Sales[CompanyKey] IN _companyKeys ),
        Sales[ContractKey]
    ) + 0

vjingzhang_1-1658458613793.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @jd8766 

 

You can try this measure

Count of Contracts =
VAR _companyKeys =
    CALCULATETABLE (
        VALUES ( Company[CompanyKey] ),
        FILTER ( Company, Company[OwnerUserKey] IN VALUES ( Sales[SoldUserKey] ) )
    )
RETURN
    COUNTX (
        FILTER ( Sales, Sales[CompanyKey] IN _companyKeys ),
        Sales[ContractKey]
    ) + 0

vjingzhang_1-1658458613793.png

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors