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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JonCross
Frequent Visitor

Count of dates < Today()-3 with filter

I am very new to PowerBI and this forum but have managed to pull in a number of API datasets and using queries to modify the data.  I was rather foolishly creating a query to filter each set of data but that means each time the date refreshes it does a refresh times the number of queries making it very slow.  I had 4 queries, I now have one and have managed to use a combination of calculated columns and measures to get the same results from just 1 query.  The problem I have is with the fourth part.  I need to get a count of dates that are less than TODAY's DATE minus 3 days.  I also need to filter and exclude the word "resolved" from another column.  Below is some of the query code I was using and am now trying to replicate using columns and measures.

FilterDatesBefore = Date.AddDays(DateTime.Date(DateTime.LocalNow()), -3),  //sets the date in the variable
#"Filtered Rows" = Table.SelectRows(#"Expanded pagedetails", each ([status] <> "Resolved")),  //removes any rows with Resolved

#"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [updated_at] < FilterDatesBefore)  //gets the remaining data

 

Hope someone can help as have been trawling Google for a while on this. TIA.

1 ACCEPTED SOLUTION

Apologies for this.  I persevered and have managed to make this work.  I had to learn a basic skill in using multiple filters which unlocked the solution for me.  My measure code is below.

Stale tickets =
CALCULATE(COUNTROWS('all tickets'),
FILTER('all tickets', 'all tickets'[status] <> "Resolved"),
FILTER('all tickets','all tickets'[updated_at]<TODAY()-3))

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Can you supply some sample data for this? I am pretty sure this is possible, but M code is finicky enough that I won't give you somethign that I haven't tested. See links below on how to do it.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Apologies for this.  I persevered and have managed to make this work.  I had to learn a basic skill in using multiple filters which unlocked the solution for me.  My measure code is below.

Stale tickets =
CALCULATE(COUNTROWS('all tickets'),
FILTER('all tickets', 'all tickets'[status] <> "Resolved"),
FILTER('all tickets','all tickets'[updated_at]<TODAY()-3))
Greg_Deckler
Super User
Super User

@ImkeF @edhans

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors