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
water-guy-5
Helper III
Helper III

Create a measure that text filters and counts by both past and present dates

Hello, I have a list of dates (both past and upcoming) that I am hoping to provide COUNT expressions on or something of that nature based on the status of the service job. Below is some dummy data.

FOR PBI.png

 

Basically, I am trying to write a couple of measure that will appear on Cards and give basic indiciators of progress or completion.
Measure 1 - I would like an expression that counts a row when (a. the end date is past the current date and b. the 'Status' column contains any text that is not "closed" - I believe it is something along the lines of <>"closed" but I do not  know exactly the input. (I attached the status column to help demonstrate that there are multiple entries for status so I would prefer some sort of "does not contain" text filter). So basically, = Count(if(End date = >today(), staus<>"closed"). I know this is incorret, but just giving you an idea. 


Measure 2 - I would like an expression that counts the number of rows complete. Essentially, the start date needs to be within 30 days of the current date and the 'Status' column needs to return "closed". Basically, finished jobs within the last month. 

Measure 3 - I would like an expression that lets me know about upcoming start dates in the next 30 days from current date. Start date 30 days or less form current date.

 

Measure 4 - I would like an expression that lets me know about upcoming start dates in the next 7 days from current date. Start date 7 days or less form current date.

Thank you SO much in advance if you take the time to help me out. These feel simple, just getting the formatting with dates a little wrong. Cheers! 😀

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi  @water-guy-5 ,

base table:

vluwangmsft_0-1627869606954.png

 

Try like below:

measure1: 

Measure1 = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[End Date] >= TODAY ()
            && 'Table'[Status] <> "Closed"
    )
)

measure2:

Measure2 = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[End Date] >= TODAY ()-30
            && 'Table'[Status] = "Closed"
    )
)

measure 3 and meausre 4 need to calculae new table,if use in base table ,will return the below error:

vluwangmsft_1-1627869749596.png

measure :

Measure33 = 
CALCULATETABLE( 
    VALUES('Table'[Start Date]),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Start Date] >= TODAY ()
            && 'Table'[Start Date] <=TODAY ()+30
    ))

And measure 4:

Measure4 = 
CALCULATETABLE( 
    VALUES('Table'[Start Date]),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Start Date] >= TODAY ()
            && 'Table'[Start Date] <=TODAY ()+7
    ))

Final will get:

vluwangmsft_2-1627869818315.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

View solution in original post

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi  @water-guy-5 ,

base table:

vluwangmsft_0-1627869606954.png

 

Try like below:

measure1: 

Measure1 = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[End Date] >= TODAY ()
            && 'Table'[Status] <> "Closed"
    )
)

measure2:

Measure2 = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[End Date] >= TODAY ()-30
            && 'Table'[Status] = "Closed"
    )
)

measure 3 and meausre 4 need to calculae new table,if use in base table ,will return the below error:

vluwangmsft_1-1627869749596.png

measure :

Measure33 = 
CALCULATETABLE( 
    VALUES('Table'[Start Date]),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Start Date] >= TODAY ()
            && 'Table'[Start Date] <=TODAY ()+30
    ))

And measure 4:

Measure4 = 
CALCULATETABLE( 
    VALUES('Table'[Start Date]),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Start Date] >= TODAY ()
            && 'Table'[Start Date] <=TODAY ()+7
    ))

Final will get:

vluwangmsft_2-1627869818315.png

 

Wish it is helpful for you!

 

Best Regards

Lucien

Had to do a bit of tweaking on my end since I forgot to include all of my information (different info from different tables) but all in all it worked!!!! Thanks so much!

 

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.