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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
RichOB
Post Patron
Post Patron

Need help getting an active count measure

Hi, I posted something similar recently and need to know how to make some slight changes for a different result. I need to know the number of Counties that are active in each quarter. Using the table below, the 2024/2025 financial quarters should be:

 

Q1 - 3

Q2 - 3

Q3 - 2 

Q4 - 2

 

CountiesPropertyCreated_date Decommissioned_Date
EdinburghL101/01/2022 
EdinburghL201/01/202205/04/2024
EdinburghL301/01/2022 
Glasgow L401/01/202201/09/2024
Glasgow L501/01/202201/09/2024
Glasgow L601/08/202401/09/2024
Glasgow L701/01/202201/09/2024
Glasgow L801/01/202201/09/2024
ManchesterL901/01/2022 
ManchesterL1001/10/202401/02/2025

 

If a Decommissioned_Date is blank, that means the Property and County is active.

As L4-L8 (Glasgow) was decommissioned on 01/09/2024, it was technically active in July and August and therefore needs to be counted in Q2.

 

Thanks

1 ACCEPTED SOLUTION

Hi @RichOB,

 

You can add a YearQuarter column to your existing Calendar table like below

 

YearQuarter =
'Calendar'[Year] & " Q" & 'Calendar'[Quarter]

 

And then update your measure as 

 

Active Counties =
CALCULATE (
DISTINCTCOUNT ( Properties[County] ),
FILTER (
Properties,
Properties[Created_date] <= MAX ( 'Calendar'[Date] ) &&
(
ISBLANK ( Properties[Decommissioned_Date] ) ||
Properties[Decommissioned_Date] > MIN ( 'Calendar'[Date] )
)
)
)

 

This way you don't have to add table/column manually and it'll be updated dynamically.

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

View solution in original post

6 REPLIES 6
v-mdharahman
Community Support
Community Support

Hi @RichOB,

Thanks for reaching out to the Microsoft fabric community forum.

It looks like you are trying to get the data of all the active counties in a quarter. As @grazitti_sapna and @mark_endicott both have responded to your query, kindly go through their response and check if it answers your query.

 

I would also take a moment to thank @grazitti_sapna and @mark_endicott, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

grazitti_sapna
Super User
Super User

Hi @RichOB,

 

To calculate the number of active Counties per quarter (based on active properties within each County), we need to evaluate whether each property was active at any point during the quarter, then count distinct Counties per quarter.

 

We need to create a quarte table, use below DAX

 

QuarterPeriods =
DATATABLE (
"Quarter", STRING,
"StartDate", DATE,
"EndDate", DATE,
{
{"Q1", DATE(2024,4,1), DATE(2024,6,30)},
{"Q2", DATE(2024,7,1), DATE(2024,9,30)},
{"Q3", DATE(2024,10,1), DATE(2024,12,31)},
{"Q4", DATE(2025,1,1), DATE(2025,3,31)}
}
)

 

Now create a measure to count active Counties, Use below DAX

 

Active Counties =
VAR SelectedStart = SELECTEDVALUE(QuarterPeriods[StartDate])
VAR SelectedEnd = SELECTEDVALUE(QuarterPeriods[EndDate])

RETURN
CALCULATE(
DISTINCTCOUNT(Properties[Counties]),
FILTER(
Properties,
Properties[Created_date] <= SelectedEnd &&
(
ISBLANK(Properties[Decommissioned_Date]) ||
Properties[Decommissioned_Date] > SelectedStart
)
)
)

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

 

Hi @grazitti_sapna thanks for your reply! Does this mean that if I want to add 2025 data I would need to add 4 more quarter dates to the first measure? I should have said I'm working with live data and already have a calendar, if that matters? Here's my calendar:

Qs1.png


Hi @RichOB,

 

You can add a YearQuarter column to your existing Calendar table like below

 

YearQuarter =
'Calendar'[Year] & " Q" & 'Calendar'[Quarter]

 

And then update your measure as 

 

Active Counties =
CALCULATE (
DISTINCTCOUNT ( Properties[County] ),
FILTER (
Properties,
Properties[Created_date] <= MAX ( 'Calendar'[Date] ) &&
(
ISBLANK ( Properties[Decommissioned_Date] ) ||
Properties[Decommissioned_Date] > MIN ( 'Calendar'[Date] )
)
)
)

 

This way you don't have to add table/column manually and it'll be updated dynamically.

 

🌟 I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
💡 Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
🎖 As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
🔗 Curious to explore more? [Discover here].
Let’s keep building smarter solutions together!

Thanks so much this is fantastic!

mark_endicott
Super User
Super User

@RichOB - If you'd like an answer to this, more information is necessary. 

 

Let's start with:

 

1) was your last question answered? 

2) if yes, can you post the link?

3) do you have a date table that defines the Quarters?

4) does this date table have a relationship to the table with your counties and decomissioned dates?

5) what DAX have you tried so far?

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.