cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Frequent Visitor

Check Date From today to last 30 days

Hey All,

Thank you in advance for helping me out in this. I have a data where there is a column for continuous dates over last 10 months, I have to create a measure where I need to check whether the last 30 dates from today is present or not , if it is it then "No failures" if it doesn't thenn count the number of dates that are missing.

Kind Regards.

1 ACCEPTED SOLUTION
Community Support

Hi @SS_1122 ,

You can try this measure to achieve your goal. My Sample has data from 2022/10/01 to 2022/12/12, today is 2022/11/14. Last 30 dates is from 2022/11/15 to 2022/12/14. So the measure result should return 2.

``````Last 30 dates from today is present or not =
VAR _Today =
TODAY ()
VAR _Last30Days =
CALENDAR ( _Today + 1, _Today + 30 )
_Last30Days,
"Flag", IF ( [Date] IN VALUES ( 'Table'[Date] ), 1, 0 )
)
VAR _Count =
COUNTX ( FILTER ( _ADDFlag, [Flag] = 0 ), [Date] )
RETURN
IF ( _Count = 0, "No failures", _Count )``````

Result is as below.

Best Regards,
Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Solution Sage

DAX Measure:

My Count of last 30 days = CALCULATE ( DISTINCTCOUNT('Table'[Dates] ) , 'Table'[Dates] > DATEADD( DAY, -30, TODAY () )

Note this is 'airware', may not be totally accurate.

You may also need a second filter in the CALCULATE function of: 'Table'[Dates] < TODAY()

Frequent Visitor

This gives an error saying 'DATEADD' has been used as a tbale filter expression.

I tried something like this :

Last 30 days = CALCULATE ( DISTINCTCOUNT('Sheet1'[Dates] ) , 'Sheet1'[Dates] > DATEADD(Sheet1[Dates], -30,  DAY() )
The data is only this

Community Support

Hi @SS_1122 ,

You can try this measure to achieve your goal. My Sample has data from 2022/10/01 to 2022/12/12, today is 2022/11/14. Last 30 dates is from 2022/11/15 to 2022/12/14. So the measure result should return 2.

``````Last 30 dates from today is present or not =
VAR _Today =
TODAY ()
VAR _Last30Days =
CALENDAR ( _Today + 1, _Today + 30 )
_Last30Days,
"Flag", IF ( [Date] IN VALUES ( 'Table'[Date] ), 1, 0 )
)
VAR _Count =
COUNTX ( FILTER ( _ADDFlag, [Flag] = 0 ), [Date] )
RETURN
IF ( _Count = 0, "No failures", _Count )``````

Result is as below.

Best Regards,
Rico Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors