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
grggmrtn
Post Patron
Post Patron

Need a measure - number of MIN[Date] and MAX[Date] per person, per service

My data looks something like this:

PersonID	Service	Date
1	One	01-01-2019
1	One	02-01-2019
1	One	03-01-2019
1	Two	01-02-2019
1	Two	02-02-2019
1	Two	03-02-2019
1	Two	04-02-2019
2	One	01-03-2019
2	One	02-03-2019
2	One	03-03-2019
2	One	04-03-2019
2	Two	05-03-2019
2	Two	06-03-2019
2	Two	07-03-2019
3	One	01-04-2019
3	One	02-04-2019
3	One	03-04-2019
3	One	01-05-2019
3	One	02-05-2019
3	One	03-05-2019
3	One	04-05-2019
3	One	05-05-2019

I need to find out how many times someone started a service. It can be different services per person (as in [PersonID]=1 and 2), but it can also be the same service started twice (as in [PersonID]=3)

 

The measure for the above table should come up with the result = 6

 

 

 

I also need a measure for the final date, but I'm assuming that will be easy once I can figure out how to make the first measure work. The caveat for that is that the final date should <> Today()

 

Anyone?

1 ACCEPTED SOLUTION
grggmrtn
Post Patron
Post Patron

I found the solution myself.

 

In our databases I found a unique ID for each [Service]

 

So I added columns for start and stop dates:

StartDate = 
CONCATENATE(
CALCULATE (
    MIN ( Services[Date] );
    ALL ( Services );
    Services[Service ID] = EARLIER ( Services[Service ID] )
); " - " & Services[Service ID])

Concatenating them so that my measure is just a basic DISTINCTCOUNT, giving me the number of [StartDate].

 

Maybe not the most graceful way of doing it, but it worked as needed.

View solution in original post

1 REPLY 1
grggmrtn
Post Patron
Post Patron

I found the solution myself.

 

In our databases I found a unique ID for each [Service]

 

So I added columns for start and stop dates:

StartDate = 
CONCATENATE(
CALCULATE (
    MIN ( Services[Date] );
    ALL ( Services );
    Services[Service ID] = EARLIER ( Services[Service ID] )
); " - " & Services[Service ID])

Concatenating them so that my measure is just a basic DISTINCTCOUNT, giving me the number of [StartDate].

 

Maybe not the most graceful way of doing it, but it worked as needed.

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.