Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Filter value before a number of days

Hi,

I have a table below : 

NameDate
Name 1 01/02/2019
Name 202/02/2019
Name 303/02/2019
Name 404/02/2019
Name 505/02/2019
Name 606/02/2019
Name 707/02/2019
Name 808/02/2019
Name 909/02/2019
Name 10

01/02/2023

Name 1102/03/2023
Name 1203/03/2023
Name 1304/03/2023
Name 1405/03/2023
Name 1506/03/2023
Name 1607/03/2023
Name 1708/03/2023
Name 1809/03/2023
Name 1910/03/2023
Name 2011/03/2023

 

I would like to count the total name before 20 days (today 16/03/2023). 

The result should be  :  10

 

NameDate
Name 1 01/02/2019
Name 202/02/2019
Name 303/02/2019
Name 404/02/2019
Name 505/02/2019
Name 606/02/2019
Name 707/02/2019
Name 808/02/2019
Name 909/02/2019
Name 10

01/02/2023

 

Thank you in advance.

 

9 REPLIES 9
KeyurPatel14
Responsive Resident
Responsive Resident

Hi @Anonymous ,
I hope you only want the count of names as you mentioned in the post so according to that I have implemented the same scenario like your and got the expected output.
So you have to perform below steps in order to solve your peoblem.

I have created one measure named M2 as you can see in the image.

KeyurPatel14_0-1679037161314.png

I have named my table as Table3 so dont be confused.
I have plotted the above measure M2 in the card visual as you can see in the image.

KeyurPatel14_1-1679037245471.png

As today's date is 17/03/2023 so the date before 20 days from today is 26/02/2023 as you said in the reply.

I hope this will solve your probem and still if you have any queries then please let me know.
And if this helps you then please give it kudos and mark it as a solution.
Thank you. 
So as per the data in the table you can see we have 11 records before 26/02/2023 as the date for Name 12 is 03/03/2023 so it will not be counted according to the logic so the count should be 11 and I got the result.



Anonymous
Not applicable

Hi,

thank you for your help . 

I got the following error when applies the dax to my dataset : 

Could you please help 

MdxScript(Model) (347, 19) Calculation error in measure 'Measure'[A]: A date column containing duplicate dates was specified in the function call 'DATESBETWEEN'. This is not supported.

 

MohammadLoran25
Solution Sage
Solution Sage

Hi,

Not Clear. What do you mean by before 20 days?

Anonymous
Not applicable

I meant before the last 20 days (>20 days). For example : today is 17 Mar, I want to extract the data of (17 Mar ) minus 20 days. It means the data before 26 Feb

Okay. Assume you have a separate date table which has relationship with your Name and Date Table that is provided above.

You need to create a measure as below to achieve what you want:

 

CALCULATE (
    COUNTROWS( VALUES( TABLE[NAME] )),
    FILTER ( ALL ( DateTable ), DateTable[Date] <= TODAY () - 20 )
)

 

If it solves your problem, then please consider Accepting it as the solution
Regards,
Loran

Anonymous
Not applicable

Hi, 

It doesn't work. 😞

HI @Anonymous ,
It is working as expected on sample data as I shared images with you.
Please share the exact problem and share the pbix if you can.
Thank you.

Why? I checked it on a sample data and it works.

If you can, please share your power bi file (a sample would be great as well if you have sensitive data)

HI @Anonymous ,
You only want the count of records right?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors