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
pedroccamaraDBI
Post Partisan
Post Partisan

COUNT from other table

Hello guys
From this model, i would like to be able to count all documentID (Document) that belong to a certain seller name and/or seller type (ContractSeller). Each saller may have more than 1 document and the seller type can have more than one value
apagar0.jpeg
Can you help?
Thanks a lot

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @pedroccamaraDBI ,

 

Per the description, I create some sample data and build the following relationships for them.

ContractSaller Table

vcazhengmsft_0-1646113256194.png

 

Contract Table

vcazhengmsft_1-1646113256196.png

 

Document Table

vcazhengmsft_2-1646113256197.png

 

vcazhengmsft_0-1646127211812.png

 

Then, create the following Measure.

 

CountDocument =

CALCULATE (

    DISTINCTCOUNT ( Document[DocumentID] ),

    TREATAS ( VALUES ( ContractSaller[ContractID] ), Document[ContractID] )

)

 

 

The result should look like this.

vcazhengmsft_4-1646113256198.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @pedroccamaraDBI ,

 

Per the description, I create some sample data and build the following relationships for them.

ContractSaller Table

vcazhengmsft_0-1646113256194.png

 

Contract Table

vcazhengmsft_1-1646113256196.png

 

Document Table

vcazhengmsft_2-1646113256197.png

 

vcazhengmsft_0-1646127211812.png

 

Then, create the following Measure.

 

CountDocument =

CALCULATE (

    DISTINCTCOUNT ( Document[DocumentID] ),

    TREATAS ( VALUES ( ContractSaller[ContractID] ), Document[ContractID] )

)

 

 

The result should look like this.

vcazhengmsft_4-1646113256198.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Thanks a lot @v-cazheng-msft 

PijushRoy
Super User
Super User

Hi @pedroccamaraDBI 

Can you please share sample data or pbix file




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.