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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
TBSST
Frequent Visitor

Filtering based on x days

Hi all, 

 

i am trying to work on a dax function to show overdue reports. I currently have multipel IDs with different dates on the report and at what stage they conducted the report. I would like to take the last report they did, and count how many are overdue. 

 

Example: 

ClientTypeDate
1Start1/01/2023
2Start1/01/2023
3Start1/01/2023
1Interim1/02/2023
2Interim1/02/2023
1End

1/03/2023

persume today is 1/3/23.

 

So in my final number, i want to identify based on the last report recorded, how many reports have not been done within the last 31 days, excluding clients who have an exited type. so final number here would be 1, because client 2 last report was within 31 days, however client 3 is overdue based on their last report, and exclding client 1 becuase their type is End. 

 

Thank you. 

1 ACCEPTED SOLUTION
Mahesh0016
Super User
Super User

@TBSST  I hope this helps you. Thank You.

It looks like you want to create a DAX measure in Power BI to calculate the number of overdue reports based on certain conditions. In your example, you want to count the clients whose last report was not done within the last 31 days and exclude clients with an "End" type report.

Here's how you can achieve this using DAX:

```dax
OverdueReportsCount =
VAR MaxDate = TODAY() -- Current date
VAR FilteredTable =
FILTER(
YourTableName, -- Replace with the actual name of your table
NOT(ISBLANK([Date])) && [Type] <> "End"
)
VAR ClientMaxDate =
SUMMARIZE(
FilteredTable,
[Client],
"LastReportDate", MAX([Date])
)
VAR OverdueClients =
FILTER(
ClientMaxDate,
[LastReportDate] <= MaxDate - 31
)
RETURN
COUNTROWS(OverdueClients)
```

Here's what the DAX measure does step by step:

1. The `FilteredTable` variable filters out rows where the date is blank or the report type is "End".

2. The `ClientMaxDate` variable calculates the maximum date for each client using the `SUMMARIZE` function.

3. The `OverdueClients` variable filters the `ClientMaxDate` table to include only clients whose last report date is more than 31 days ago.

4. Finally, the measure returns the count of rows in the `OverdueClients` table, which gives you the count of clients with overdue reports based on your criteria.

Make sure to replace `YourTableName` with the actual name of your table in Power BI. Also, make sure your date columns are recognized as dates in Power BI for this DAX code to work correctly.

You can create a new DAX measure in your Power BI report and use this formula. This measure will then display the count of overdue reports based on your criteria.

View solution in original post

2 REPLIES 2
Mahesh0016
Super User
Super User

@TBSST  I hope this helps you. Thank You.

It looks like you want to create a DAX measure in Power BI to calculate the number of overdue reports based on certain conditions. In your example, you want to count the clients whose last report was not done within the last 31 days and exclude clients with an "End" type report.

Here's how you can achieve this using DAX:

```dax
OverdueReportsCount =
VAR MaxDate = TODAY() -- Current date
VAR FilteredTable =
FILTER(
YourTableName, -- Replace with the actual name of your table
NOT(ISBLANK([Date])) && [Type] <> "End"
)
VAR ClientMaxDate =
SUMMARIZE(
FilteredTable,
[Client],
"LastReportDate", MAX([Date])
)
VAR OverdueClients =
FILTER(
ClientMaxDate,
[LastReportDate] <= MaxDate - 31
)
RETURN
COUNTROWS(OverdueClients)
```

Here's what the DAX measure does step by step:

1. The `FilteredTable` variable filters out rows where the date is blank or the report type is "End".

2. The `ClientMaxDate` variable calculates the maximum date for each client using the `SUMMARIZE` function.

3. The `OverdueClients` variable filters the `ClientMaxDate` table to include only clients whose last report date is more than 31 days ago.

4. Finally, the measure returns the count of rows in the `OverdueClients` table, which gives you the count of clients with overdue reports based on your criteria.

Make sure to replace `YourTableName` with the actual name of your table in Power BI. Also, make sure your date columns are recognized as dates in Power BI for this DAX code to work correctly.

You can create a new DAX measure in your Power BI report and use this formula. This measure will then display the count of overdue reports based on your criteria.

Fantastic. Thank you for the response. This is indeed the solution i needed! 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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