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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Create a virtual table with a measure and distinctcount

Hi all.


Can someone please help me solving this problem with me? I would really appreciate it.

 

So;

I have one table who looks like this:

|ID| |Coverage_x| |Coverage_y|


The ID here does not contain distinct values.

 

Then I have two fact tables connected to the first table.

The first of this contains:

|Coverage_x| |more info|


The other contains:

|Coverage_y| |more info|

 

This two tables are connected to the first on |Coverage_x| and |Coverage_y|

 

What i now want is to count distinct values in the first table with filter from the two others (Coverage_x and Coverage_y)

If this two tables was in one table i could use:
measure = CALCULATE(DISTINCTCOUNT(Table1[ID]); (Table2[Coverage_x])) || (Table2[Coverage_y])
But when they are in two seperate tables this does not work.

Then I have to make a new virtual table that contains info from all three tables and then DISTINCTCOUNT |ID| with the filters I want.

 

I cannot merge the two tables into the first, because the two other tables contains a lot of columns but a few rows.


Hope this was understandable, but please let me know if there is anything more you need to solve this.

Best regards

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Anonymous,

Please check if the following measure returns your expected result. If not, please post sample data as other's post.

Measure = CALCULATE(DISTINCTCOUNT(Table1[ID]),FILTER(Table1,Table1[Coverage_x]=RELATED(Table2[Coverage_x])||Table1[Coverage_y]=RELATED(Table3[Coverage_y])))
1.JPG

Regards,
Lydia

 

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yuezhe-msft
Employee
Employee

@Anonymous,

Please check if the following measure returns your expected result. If not, please post sample data as other's post.

Measure = CALCULATE(DISTINCTCOUNT(Table1[ID]),FILTER(Table1,Table1[Coverage_x]=RELATED(Table2[Coverage_x])||Table1[Coverage_y]=RELATED(Table3[Coverage_y])))
1.JPG

Regards,
Lydia

 

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you so much.


This worked exactly how I wanted 🙂

Marius

Greg_Deckler
Super User
Super User

Sample data that can be easily copied and pasted would help recreate but my first suggestion would be to throw a RELATED or RELATEDTABLE into your CALCULATE for your Coverage_x and Coverage_y.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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