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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MagnusJ
Frequent Visitor

Distinctcount across tables with range as condition

I am trying to perform a Distinctount with range as condition across two tables. However, since I have no relations between the tables I am having trouble finding a solution. An example below. I want to create the "Unique in range". 

Any ideas to help me find a solution would be greatly appreciated. 

 

 Problem.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @MagnusJ,

 

You can use below formula to check the matched unique product count:

Unique Count = CALCULATE(COUNTROWS(VALUES('Product'[Product])),FILTER(ALL('Product'),[Xvalue] in GENERATESERIES([MinX],[MaxX],1) && [Yvalue] in GENERATESERIES([MinY],[MaxY],1)))

ResultResult

 

Notice: I named table1 to range, table2 to product.

 

Regads,

Xiaoxin Sheng

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

HI @MagnusJ,

 

You can use below formula to check the matched unique product count:

Unique Count = CALCULATE(COUNTROWS(VALUES('Product'[Product])),FILTER(ALL('Product'),[Xvalue] in GENERATESERIES([MinX],[MaxX],1) && [Yvalue] in GENERATESERIES([MinY],[MaxY],1)))

ResultResult

 

Notice: I named table1 to range, table2 to product.

 

Regads,

Xiaoxin Sheng

Thanks for the solution! I am still checking if this is the best one or if I need to combine tables instead. 

popov
Resolver III
Resolver III

Hello,

Use this formula to define calculated column

Unique in Range=CALCULATE(DISTINCTCOUNT(Table2[Product]);
Table2[Xvalue]<=EARLIER(Table1[MaxX]) && Table2[Xvalue] >= EARLIER(Table1[MinX]); 

Table2[Yvalue] <= EARLIER(Table1[MaxY]) && Table2[Yvalue] >= EARLIER(Table1[MinY])
)

MagnusJ
Frequent Visitor

Thank you for the proposed solution! I would however like to do it without EARLIER as I have a large amount of data. Any ideas on a workaround? 

Unfortunatelly, not any ideas on a workaround. 

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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