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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jdubs
Helper V
Helper V

Measure to get a count of records created in the last 6 months

How can I create a measure to get a count of records created in the last 6 months and display this number in a Card visual?

 

I have a 'created on' date in my table that I have linked to a DimDate table.

5 REPLIES 5
Anonymous
Not applicable

Hi @jdubs ,

According to my understanding, you want to count rows when the date(maybe the endTime in DimDate table) is more than 6 months from the created_on date, right?

 

Here are my data sample:

8.20.2.1.png8.20.2.2.png

You could use the following formula:

diffMonth =
DATEDIFF (
    SELECTEDVALUE ( CreatedDate[Created on] ),
    SELECTEDVALUE ( DimDate[endTime] ),
    MONTH
)
perProCount =
CALCULATE (
    COUNT ( DimDate[Pro] ),
    FILTER (
        ALL ( DimDate ),
        [diffMonth] <= 6
            && DimDate[Pro] = MAX ( DimDate[Pro] )
    )
)
totalCount =
CALCULATE (
    COUNT ( DimDate[Pro] ),
    FILTER ( ALL ( DimDate ), [diffMonth] <= 6 )
)

My visualization looks like this:

8.20.2.3.png

 

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

Hi,

 

Thanks. Not exactly. I just want a count of all records and then a count of records created in the last 6 months. This can be displayed in a multi-row card or a clustered chart.

 

E.g.

Total # of records = 3000

Records created in the last 6 months = 1500

Hi @jdubs ,

 

You can use these measures

 

Total Records = COUNTROWS('Table')

 

Total Records Last 180 days = 
var _lastdate = LASTDATE('Table'[Audit_Date])
RETURN
CALCULATE(COUNTROWS('Table'), FILTER(ALL(Dates), Dates[Date] > _lastdate - 180  && Dates[Date] < _lastdate))

 

 

1.jpg

 

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

HI @jdubs 

 

_count = CALCULATE( COUNTROWS(table),
                                                    FILTER(table,DATEDIFF(MIN(table[created on])-MAX(table[created on]))<=6)
                                                 )

Hi Pranit,

 

Thanks. It's telling me too few arguments are being passed to DATEDIFF

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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