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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
RichOB
Post Patron
Post Patron

Measure to count totals based on a date

Hi, when the decommissioned date is empty, the property is open. Using the table below, I need to show the property count 2 ways:

 

The total number of active properties in a quarter:

2024 Q1 - 8

2024 Q2 - 8 (as L6 was created in Q2)

2024 Q3 - 9 (as L10 was created in Q3)

2024 Q4 - 7

 

At the end of the quarter, how many were remaining

2024 Q1 - 1 was decommissioned so 5 remaining

2024 Q2 - 8 

2024 Q3 - 7 as L6 + L7 as was decommissioned in Q3

2024 Q4 - 6 as L10 was decommissioned in Q4

 

NamePropertyCreated_date Decommissioned_Date
EdinburghL101/01/2022 
EdinburghL201/01/202205/04/2024
EdinburghL301/01/2022 
Glasgow L401/01/2022 
Glasgow L501/01/2022 
Glasgow L601/08/202401/11/2024
Glasgow L701/01/202210/11/2024
Glasgow L801/01/2022 
ManchesterL901/01/2022 
ManchesterL1001/10/202401/02/2025

 

Thanks!

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@RichOB , First create a date table

Then, Create a measure to count active properties in a quarter:

ActiveProperties =
CALCULATE(
COUNTROWS('Table'),
'Table'[Created_date] <= MAX('DateTable'[Date]),
OR(
ISBLANK('Table'[Decommissioned_Date]),
'Table'[Decommissioned_Date] > MAX('DateTable'[Date])
)
)

 

Create a measure to count remaining properties at the end of a quarter:

DAX
RemainingProperties =
CALCULATE(
COUNTROWS('Table'),
'Table'[Created_date] <= MAX('DateTable'[Date]),
OR(
ISBLANK('Table'[Decommissioned_Date]),
'Table'[Decommissioned_Date] > MAX('DateTable'[Date])
),
'Table'[Decommissioned_Date] > MIN('DateTable'[Date])
)

 

Use a line chart or bar chart to visualize the measures over time.
Drag the Date Table's Quarter column to the axis and the measures to the values.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

4 REPLIES 4
v-tejrama
Community Support
Community Support

Hi @RichOB ,

 

Thanks for reaching out to the Microsoft fabric community forum.

 

I faced a similar challenge and was able to resolve it by creating a DAX measure that calculates the number of active properties by quarter.

 

In my scenario, a property is considered active if it was created on or before the selected date and has either not been decommissioned or was decommissioned after the selected date.

 

To achieve this, I used a DateTable with a relationship to the Created_date column in the Properties table.


Here is the DAX :

 

ActiveProperties =
CALCULATE(
COUNTROWS(Properties),
FILTER(
ALL(Properties),
Properties[Created_date] <= MAX('DateTable'[Date]) &&
(
ISBLANK(Properties[Decommissioned_date]) ||
Properties[Decommissioned_date] > MAX('DateTable'[Date])
)
)
)


This measure, when plotted on a line chart with DateTable[YearQuarter] on the X-axis, accurately reflects how many properties were active during each quarter.

 

Please find the attached pbix file for your reference.

 

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.


Best Regards,
Tejaswi.
Community Support

 

 

govind_021
Responsive Resident
Responsive Resident

Hey @RichOB 
try this maeasure

Remaining Properties at Quarter End =
VAR EndDate = MAX('DateTable'[Date])
RETURN
CALCULATE(
COUNTROWS(Properties),
FILTER(
Properties,
Properties[Created_date] <= EndDate &&
(ISBLANK(Properties[Decommissioned_Date]) || Properties[Decommissioned_Date] > EndDate)
)
)


Best Regards
Govind Sapkade ( Microsoft Certified Data Analyst , PL 300 Certified , MS Fabric Enthusiast)
Let's Connect
Linkdin - www.linkedin.com/in/govind-sapkade-845104225
Youtube - http://www.youtube.com/@govind_dataanalyst

bhanu_gautam
Super User
Super User

@RichOB , First create a date table

Then, Create a measure to count active properties in a quarter:

ActiveProperties =
CALCULATE(
COUNTROWS('Table'),
'Table'[Created_date] <= MAX('DateTable'[Date]),
OR(
ISBLANK('Table'[Decommissioned_Date]),
'Table'[Decommissioned_Date] > MAX('DateTable'[Date])
)
)

 

Create a measure to count remaining properties at the end of a quarter:

DAX
RemainingProperties =
CALCULATE(
COUNTROWS('Table'),
'Table'[Created_date] <= MAX('DateTable'[Date]),
OR(
ISBLANK('Table'[Decommissioned_Date]),
'Table'[Decommissioned_Date] > MAX('DateTable'[Date])
),
'Table'[Decommissioned_Date] > MIN('DateTable'[Date])
)

 

Use a line chart or bar chart to visualize the measures over time.
Drag the Date Table's Quarter column to the axis and the measures to the values.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi @bhanu_gautam I wonder if you could help with a further question with this, please?

 

As long as one property is active in a quarter then the Name is considered active for that quarter. How can I show that in a countplease? So Q1-Q4 2024 would show as 3 per quarter please? as Edinburgh, Glasgow and Manchester had at least a live property, and obviously say if Manchester had a decommissioned date on all properties in a quarter, then the total would be 2 etc.

Thanks

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.