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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DimaMD
Solution Sage
Solution Sage

Need to count unique values from 7 different tables in dynamic date range

Need help,

I need to count unique companies from 7 different tables.

Each table has ID of company, dates on which records were created. Tables are connected with each other with calendar. The tas is to count summary of unique company records, that are connected to this records.

 

For example:

Table 1:

accountid: x

Createdon: 23.09.2021

createdby: Arnold

 

Table 2:

accountid: x

Createdon: 22.09.2021

createdby: Arnold

 

Table 3:

accountid: y

Createdon: 21.09.2021

createdby: Sara

 

Here we can see that we have 3 recrods in 3 different tables, that was created by 2 different users. but 2 of those tables have the same companyid, and the 3d table has different companyid, so in result we need to get 2 unique companies (account) created by 2 different users. 

 

Also we need to consider dates in calendar, so we could see how many unique companies were involved in different period of time (dates) by filtering dates "createdon" and users that created records

 

Original task considers 7 different tables, where we need to count companies.

 

Will be very grateful for help.


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@DimaMD Maybe:

Measure =
  COUNTROWS(
    DISTINCT(
      UNION(
        SELECTCOLUMNS('Table 1',[accountid]),
        SELECTCOLUMNS('Table 2',[accountid]),
        SELECTCOLUMNS('Table 3',[accountid]),
        SELECTCOLUMNS('Table 4',[accountid]),
        SELECTCOLUMNS('Table 5',[accountid]),
        SELECTCOLUMNS('Table 6',[accountid]),
        SELECTCOLUMNS('Table 7',[accountid])
      )
    )
  )


Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@DimaMD Maybe:

Measure =
  COUNTROWS(
    DISTINCT(
      UNION(
        SELECTCOLUMNS('Table 1',[accountid]),
        SELECTCOLUMNS('Table 2',[accountid]),
        SELECTCOLUMNS('Table 3',[accountid]),
        SELECTCOLUMNS('Table 4',[accountid]),
        SELECTCOLUMNS('Table 5',[accountid]),
        SELECTCOLUMNS('Table 6',[accountid]),
        SELECTCOLUMNS('Table 7',[accountid])
      )
    )
  )


Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you very much👍


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.