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

Distinct Count on ID

Helllo

 

I hope you can help?

 

I have two tables

 

Date Table

 

Start Date/Time                  End Date/Time

 

01/01/2018 11:00               01/01/2018 12:00

01/01/2018 12:00               01/01/2018 13:00

01/01/2018 13:00               01/01/2018 14:00

01/01/2018 14:00               01/01/2018 15:00

 

 

FACT Table with double entries for the UUID

 

UUID                                                       Start Date                          USER ID

hjjwehfhgwfbvwdlwkvhn                        01/01/2018 11:00             4444

hjjwehfhgwfbvwdlwkvhn                        01/01/2018 11:00             3333

jwhfdewgvjhvwbvbjwsvjb                       01/01/2018 11:30             1111

jwhfdewgvjhvwbvbjwsvjb                       01/01/2018 11:30             2222

 

 

I would like to add a column or create a measure on the Date Table that shows me how many times a Start Date in the FACT Table appears between the Start Date/Time and End Date/Time on the Date Table, per UUID

 

The Result would look like this

 

Start Date/Time                  End Date/Time                    Value

 

01/01/2018 11:00               01/01/2018 12:00                  2

01/01/2018 12:00               01/01/2018 13:00                  0

 

Thanks in advance

Joe

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You can do it like this:

=
CALCULATE (
    DISTINCTCOUNT ( FactTable[UUID] );
    FILTER (
        FactTable;
        FactTable[Start Date] >= MIN ( DateTable[Start Date/Time] )
            && FactTable[Start Date] <= MAX ( DateTable[End Date/Time] )
    )
)

Capture.JPG

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

You can do it like this:

=
CALCULATE (
    DISTINCTCOUNT ( FactTable[UUID] );
    FILTER (
        FactTable;
        FactTable[Start Date] >= MIN ( DateTable[Start Date/Time] )
            && FactTable[Start Date] <= MAX ( DateTable[End Date/Time] )
    )
)

Capture.JPG

Anonymous
Not applicable

@Anonymous Thank you for this!

themistoklis
Community Champion
Community Champion

@Anonymous

 

Create a measure which counts the dates in the fact table like this:

 

Measure = DISTINCTCOUNT('Fast Table'[Start Date])

 

Then add a table object with dimension the date from the Date Table and measure the field above 

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.

Top Solution Authors