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
cpatterson
Helper I
Helper I

How to COUNTIF within a specified date range

Hi again,

 

I'm trying to use the Gauge visual to demonstrate target completion vs actual completion based on enrollment dates. I think I need a measure to calculate how many values are in a column, but I keep running in to errors while trying to use EDATE() so I'm not sure I'm doing it quite right.

 

There are four unique under "Learning Plan Name" all with respective "Subscription Date." If they have not completed the training, "Completion Date" remains blank; however, if they have completed training, "Completion Date" has a value.

 

pbi.png

What I would like it to do is count the # of values in the "Subscription Date" column within the time allocated to complete the training to be my "target value" on the gauge visual. For example, if Silver Reel has a deadline of 12 months, I would like it count anything in "Subscription Date" that is 12 months or greater from today's date. The other "Learning Plan Name" values all have a 12 month deadline, except for one, which has a 6 month deadline. I would like it to calculate everything that should be completed, essentially.

2 REPLIES 2
MFelix
Super User
Super User

Hi @cpatterson 

 

Try the following measure:

 

Count plans out =
CALCULATE (
    COUNT ( 'Subscription Plans'[Learning Plan Name] );
    'Subscription Plans'[Completion] = "";
    FILTER (
        ALL (
            'Subscription Plans'[Subscription Date];
            'Subscription Plans'[Learning Plan Name]
        );
        'Subscription Plans'[Subscription Date]
            <= EDATE (
                TODAY ();
                IF ( 'Subscription Plans'[Learning Plan Name] = "Gold Reel"; -6; -12 )
            )
    )
)

Replace the column names by your model information and in the Gold Reel replace it by the plan that as only 6 months, in my example I call it Gold Reel to test out.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix ,

Thank you for your help! Sorry for the delay in responding to this... I created the measure but when I add it to the visual (or any visual), it says "Can't display the visual."

 

Do you have an idea on what could be causing this?

 

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.