cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
SuzieKidd
Frequent Visitor

Count people that appear in every financial year

Hi, I have a table of people with start and end dates, the start date is linked to my caldender table date and I need to be able to count the people for each financial year that the episode was open for.  I have added a column into my caldendar table to show the financial year and I'm using this as my filter, however it seems to only be counting those that started in a financial year and not counting them in subsequent years where it was still open.  I'm very new to Power BI and any help with this would be greatly appreciated.  Thank youFinancial Years.PNG

1 ACCEPTED SOLUTION

 

No problem.

If you want the count of ANY people that featured during the year, not just thse still present at the end of the year, use this measure instead:

_noofEmployeesFeatured_ot =
VAR __maxDate = MAX(calendar[date])
VAR __minDate = MIN(calendar[date])
RETURN
CALCULATE(
    DISTINCTCOUNT(yourTable[ID]),
    FILTER(
        yourTable,
        yourTable[Start Date] <= __maxDate
        && (__minDate < yourTable[End Date] || ISBLANK(yourTable[End Date]))
    )
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
BA_Pete
Super User
Super User

Hi @SuzieKidd ,

 

Try an 'over time' measure like this:

 

_noofEmployees_ot =
VAR __cDate = MAX(calendar[date])
RETURN
CALCULATE(
    DISTINCTCOUNT(yourTable[ID]),
    FILTER(
        yourTable,
        yourTable[Start Date] <= __cDate
        && (__cDate < yourTable[End Date] || ISBLANK(yourTable[End Date]))
    )
)

 

Remove or disable the relationship you have between calendar[date] and yourTable[Start Date], then put this measure into a visual with calendar[FY] and it will give you the count of people present at the end of each year.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thank you so much for this, although not giving me a count of all the people who appeared in the FY, including those that closed within the FY, this is very close to what I'm after.  Once again, thank you so much 🙂

 

No problem.

If you want the count of ANY people that featured during the year, not just thse still present at the end of the year, use this measure instead:

_noofEmployeesFeatured_ot =
VAR __maxDate = MAX(calendar[date])
VAR __minDate = MIN(calendar[date])
RETURN
CALCULATE(
    DISTINCTCOUNT(yourTable[ID]),
    FILTER(
        yourTable,
        yourTable[Start Date] <= __maxDate
        && (__minDate < yourTable[End Date] || ISBLANK(yourTable[End Date]))
    )
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Pete, thank you so much, that works like a dream.  Have a great afternoon Suzie

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors