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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Sonnet
Helper I
Helper I

Measure that calculates the count of closed actions in the last three months

Hello everyone, I have a fact table, namely the Action Table, which has a Closed date linked to the calendar date via an inactive relationship.

I am seeking to create a measure that computes the count of actions that were closed within the last three months from today’s date.

Subsequently, I want to use this measure to draw a comparison with the count of actions from the preceding three months.

 

For instance:

The first measure counts the actions closed from 19/05/2024 to 19/02/2024.

Then, I need a second measure to use in a KPI visual as the target measure, to calculate the count of closed actions in three months previously to the three months in the first measure, in our case, from 18/02/2024 to 18/11/2023.

 

Another option would be to calculate the count of closed actions in the last 90 days compared to the count of closed action between 91 and 180 days.

 

Here is the measure for closed actions without any specified dates:

Total Completed = CALCULATE(COUNT('Actions'[Date Closed]), 'Actions'[Date Closed]<>BLANK(), USERELATIONSHIP('Calendar'[Date],'Actions'[Date Closed]))+0

 

Could anyone guide me on how to accomplish this? Thanks in advance!

 

Action IdDate Closed
120/03/2023
215/06/2023
3 
402/09/2023
523/12/2023
6 
710/02/2024
823/04/2024
919/05/2024

 

3 REPLIES 3
Sonnet
Helper I
Helper I

any help is much appreaciated.

Sonnet
Helper I
Helper I

I've managed to create the measures:

 

Last 3 months = 

CALCULATE(COUNTROWS('Actions'),FILTER('Actions', 'Actions'[Date Closed]>TODAY()-90
&& 'Actions'[Date Closed]<=TODAY() &&'Actions'[Date Closed]<>BLANK() ))+0

3 months before [Last 3 months] = 
CALCULATE(COUNTROWS('Actions'),FILTER('Actions', 'Actions'[Date Closed]>TODAY()-180
&& 'Actions'[Date Closed]<=TODAY()-91 &&'Actions'[Date Closed]<>BLANK()))+0

The results are es expected when used in a card visual. If I used them in a KPI visual with [Last 3 months] at Value, Month and Year column from the calendar table as Trend Axis, and 3 months before [Last 3 months] at the Target, all I get is 0, which is not expected.

Sonnet_0-1716157330031.png

Do you know why?

Greg_Deckler
Community Champion
Community Champion

@Sonnet Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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