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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
cake28424
Frequent Visitor

Dynamic Count If Measure

Hi! I have been trying to create a dynamic count if measure but am struggling a lot to do this. Essentially, I want to count the number of active IDs (using dummy data to not share confidential data) within a department at a given time.

When I filter to a particular time period, say 2024, I want a measure to return the number of IDs within a department. So Marketing would return 1, Finance would return 1, HR would return 1, and Sales would return 2. This measure needs to be on a department basis so each ID row returns the active count of all active IDs within a department. I need to use a measure instead of a column so this metric works dynamically with the date filter I have set up (used a date table that accounts for contract start and end year). 

cake28424_0-1710187106903.png

Can someone help me figure out how to do this? Happy to provide any clarification.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cake28424 ,

First of all, many thanks to @lbendlin  for your very quick and effective replies, and I will give some additions below:

1.Create the simple table.

vjiewumsft_0-1710379009956.png

2.Create the new measure to count.

 

Dynamic_Count_ID = 
VAR yea = 2024
RETURN
CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        'Table'[Start year] <= yea &&
        'Table'[End year] >= yea
    )
)

 

3.Drag the department field and measure into the table visual.

vjiewumsft_1-1710379098122.png

4.The result is shown below.

vjiewumsft_3-1710379130030.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @cake28424 ,

First of all, many thanks to @lbendlin  for your very quick and effective replies, and I will give some additions below:

1.Create the simple table.

vjiewumsft_0-1710379009956.png

2.Create the new measure to count.

 

Dynamic_Count_ID = 
VAR yea = 2024
RETURN
CALCULATE(
    COUNTROWS('Table'),
    FILTER(
        'Table',
        'Table'[Start year] <= yea &&
        'Table'[End year] >= yea
    )
)

 

3.Drag the department field and measure into the table visual.

vjiewumsft_1-1710379098122.png

4.The result is shown below.

vjiewumsft_3-1710379130030.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

lbendlin
Super User
Super User

lbendlin_0-1710200356503.png

 

Hi @lbendlin  

Thanks for taking a look! I opened up your solution and saw that the customer IDs under the sales department are returning the individual count instead of the department count when the year is 2024. Would want both of these numbers to show 2 instead of 1 each to reflect the department size at the time of 2024.

cake28424_0-1710201628929.png

Do you know if this is possible/how I can achieve this?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.

Top Solution Authors
Top Kudoed Authors