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
Raul_Cristobal
Regular Visitor

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.png

1 ACCEPTED SOLUTION

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

Manoj_Nair_0-1670266020180.png

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

 

View solution in original post

5 REPLIES 5
Raul_Cristobal
Regular Visitor

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.png

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

Manoj_Nair_0-1670266020180.png

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

 

Thanks!!!!

Manoj_Nair
Solution Supplier
Solution Supplier

@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

v-yinliw-msft
Community Support
Community Support

Hi @Raul_Cristobal ,

 

You can try this method:

Sample data:

vyinliwmsft_0-1670309962443.png

New two measures:

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

The result is:

vyinliwmsft_1-1670309985165.png

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.

 

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.