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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
grggmrtn
Post Patron
Post Patron

DISTINCTCOUNT per category, using relation

Hey everyone - having a bit of a problem getting the data I need. Here's my data:

PersonIDDateRegisteredStartDate
101-01-202001-01-2020
102-01-202003-02-2020
103-02-202001-01-2020
205-05-202008-12-2019
206-06-202001-01-2020
207-06-202003-05-2020
312-07-202007-10-2020
314-10-202001-01-2020
416-10-202001-01-2020

 

This table is related to my date table on DateRegistered using the date table, but I also have an inactive relation on StartDate to the date table, because I need to find out how many unique StartDate there are per month.

 

this is the DAX I'm using now:

 

 

 

Antal indskrivninger = 
CALCULATE(
    DISTINCTCOUNT('table'[StartDato]),
    USERELATIONSHIP('table'[StartDato],Dato[Dato])
    )

 

 

 

and it is giving me of course, a unique count of StartDate per month. So the result for the above data is 5.

 

BUT

 

What I NEED is for it to give me unique number of StartDate per PersonID - so the result for above should be:

PersonIDNumber of DistinctStartDato
12
23
32
41

and it should show me a total of 8, not 5.

 

Any idea how I can modify my DAX to give me the results I need?

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@grggmrtn 

Use your measure and modify as follows:

Antal indskrivninger = 

SUMX(
    SUMMARIZE(Table,Table[PersonID],Table[StartDate]),
    CALCULATE(
        DISTINCTCOUNT('Table'[StartDate]),
        USERELATIONSHIP(Table[StartDate],Dato[Date])
    )
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@grggmrtn 

Use your measure and modify as follows:

Antal indskrivninger = 

SUMX(
    SUMMARIZE(Table,Table[PersonID],Table[StartDate]),
    CALCULATE(
        DISTINCTCOUNT('Table'[StartDate]),
        USERELATIONSHIP(Table[StartDate],Dato[Date])
    )
)

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Beautiful @Fowmy - thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.