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

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

3 REPLIES 3
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






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.