cancel
Showing results for
Did you mean:
New Member

## Count values ​​before and after today's date in month

Hello, I want to count the values ​​that exist before and after today's date during the month.

For example, in the table there are 84 values ​​in the month of December. Today is 5/12/2022 (today()) therefore 2 measurements should be returned.
- There are 6 values ​​(rows) before 12/5/2022 (today())
- There are 77 values ​​(rows) after 12/5/2022 (today()) not including the same day.

And so on for the months in the filter.

1 ACCEPTED SOLUTION
Resolver IV

@Raul_Cristobal - Try this solution and let me know if this meets your requirement. Many Thanks

``After Today = COUNTX(FILTER(Maintenance,Maintenance[DIA] > DAY(TODAY())), Maintenance[MES])``
``Before Today = COUNTX(FILTER(Maintenance,Maintenance[DIA] < DAY(TODAY())), Maintenance[MES])``

5 REPLIES 5
New Member

Hello, I want to count the values ​​that exist before and after today's date during the month.

For example, in the table there are 84 values ​​in the month of December. Today is 5/12/2022 (today()) therefore 2 measurements should be returned.
- There are 6 values ​​(rows) before 12/5/2022 (today())
- There are 77 values ​​(rows) after 12/5/2022 (today()) not including the same day.

And so on for the months in the filter.

Resolver IV

@Raul_Cristobal - Try this solution and let me know if this meets your requirement. Many Thanks

``After Today = COUNTX(FILTER(Maintenance,Maintenance[DIA] > DAY(TODAY())), Maintenance[MES])``
``Before Today = COUNTX(FILTER(Maintenance,Maintenance[DIA] < DAY(TODAY())), Maintenance[MES])``

New Member

Thanks!!!!

Resolver IV

@Raul_Cristobal, saw a similar post from you yesterday, was that similar or different. Post link https://community.powerbi.com/t5/Power-Query/Count-values-before-and-after-today-s-date-in-month/m-p.... Pls confirm. Thanks

Community Support

You can try this method:

Sample data:

New two measures:

``BeforeToday = CALCULATE(COUNTROWS('Table'),FILTER('Table', 'Table'[Date] < TODAY())) ``
``AfterToday = CALCULATE(COUNTROWS('Table'),FILTER('Table', 'Table'[Date] > TODAY()))``

The result is:

Hope this helps you.

Here is my PBIX file.

Best Regards,

Community Support Team _Yinliw

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

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors