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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Neqom
Frequent Visitor

Count Based on Date in the same Table

I have a Table with the below structure:

ID - Date

1 - 1/Jan/2020
1 - 2/Jan/2020
2 - 1/Jan/2020
3 - 1/Jan/2020
4 - 5/Jan/2020
...

Where ID appears multiple times. I need a measure in a Table Visual where a new column called "Last  30 days" shows the amount of entries of the table in the last 30 days

ID - Amount
1 - 2
2 - 1
3 - 1
4 - 1

Important to note that I can't add a filter to the visual since the visual contains more data. Like ID that have no entries in the last 30 days or other information that if I add the filter will be remove from the visual. Also the full visual has information from multiple tables.

I need something like Count(ID) where Date+30>=Today()

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Neqom ,

Here's my modified data, otherwise unchanged.

vhuijieymsft_1-1715927922598.png

 

Just select Show item with no data in the ID field and now, IDs with no counts in the last 30 days show blank.

vhuijieymsft_0-1715927866129.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Neqom ,

 

Thanks for the reply from Awm .

 

First, create a measure to store your definition of today=2020/1/10:

_today = DATE(2020,1,10)

 

Then, create a measure to count the number of rows:

Count = CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table'.
            'Table'[Date] >= [_today] - 30 && 'Table'[Date] < [_today]
        )
    )

 

The page visualization is shown below:

vhuijieymsft_0-1715061439915.png

 

If you want to calculate the last 30 days of data for today (2024/05/07), you can replace _today with Today().

Count = CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            'Table'[Date] >= TODAY() - 30 && 'Table'[Date] < TODAY()
        )
    )

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hello!
Thanks for your help.
Iy works. however it shows blank instead of "0" for ID where there is nothing in the last 30 days
Sorry for no specify that at the beginning.


Anonymous
Not applicable

Hi @Neqom ,

Here's my modified data, otherwise unchanged.

vhuijieymsft_1-1715927922598.png

 

Just select Show item with no data in the ID field and now, IDs with no counts in the last 30 days show blank.

vhuijieymsft_0-1715927866129.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Awm
Advocate I
Advocate I

Last 30 Days =
VAR MaxDate = MAX('YourTable'[Date])
VAR MinDate = MAX('YourTable'[Date]) - 30
RETURN
CALCULATE(
COUNTROWS('YourTable'[Date]),
'YourTable'[Date] >= MinDate && 'YourTable'[Date] <= MaxDate
)

Neqom
Frequent Visitor

Note* Example asuming that Today = 10/Jan/2020

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.