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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
pedroccamaraDBI
Post Partisan
Post Partisan

distinctcount with crossfilter?

Hello all
I would like to have just one measure to count all distinct contractID.
Here is my model
apagarmodel.JPG
My main table, documents, is connected with dates with an active connection. My other table, contracts, has a dates connection but it is inactive. I would like to count all distinct contractID, from entities, from several columns filters from documents, as well as from contracts and also, by seller type, from contractseller. This last table is connected to contracts with a bi directional connection. 
My desire visual would be, filtered by month, year and seller type. On the context visual i would like to see all contracts by seller name, month and status doc (from document table). Like this:

apagarseguros.JPG
Thank you all so much

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@pedroccamaraDBI , if contract and document are two fact, they should join. Or should be merged into one fact.

 

even if the join is inactive you can use these dates filter like

 

new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = minx(allselected(Date1),Date1[Date])
return
calculate( distinctCOUNT(Contrcat[Contract ID]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

if need add cross join to remove date join with document

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
pedroccamaraDBI
Post Partisan
Post Partisan

Thank you so much guys!!!!

tamerj1
Super User
Super User

Hi @pedroccamaraDBI 
I don't see any reason not to use

Contract ID Count =
CALCULATE (
    DISTINCTCOUNTNOBLANK ( Contract[ContractID] ),
    USERELATIONSHIP ( 'Dates'[Date], Contract[StartDate] )
)

Please let me know if this answers your query.
 

amitchandak
Super User
Super User

@pedroccamaraDBI , if contract and document are two fact, they should join. Or should be merged into one fact.

 

even if the join is inactive you can use these dates filter like

 

new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = minx(allselected(Date1),Date1[Date])
return
calculate( distinctCOUNT(Contrcat[Contract ID]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

 

if need add cross join to remove date join with document

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.