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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
Frequent Visitor

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors