Forum Discussion

cottrera's avatar
cottrera
Post Prodigy
6 years ago
Solved

Count previous 7 days

Hi 

I have a table called Poperty and with a column called buld date. I need DAX to count the number of dates for the previous 7 days .

FOr the example table below I would expect the resulting count to = 7

 

Table_Property
 
Date Built
18/11/2019
17/11/2019
17/11/2019
14/11/2019
14/11/2019
14/11/2019
14/11/2019
10/11/2019
09/11/2019
09/11/2019
09/11/2019
09/11/2019
05/11/2019
05/11/2019
05/11/2019
05/11/2019

 

thank you

 

RIchard

  • Anonymous's avatar
    Anonymous
    6 years ago

    You can use the today function in a calculate like the following:

    Measure =
    CALCULATE (
        COUNT ( 'Table'[Date Built] );
        'Table'[Date Built]
            >= ( TODAY () - 7 )
    )

    Kind regards
    Joren Venema

    Data & Analytics Consultant
    If this reply solved your question be sure to mark this post as the solution to help others find the answer more easily. 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi cottrera,


    Create a measure to count dates for the past 7 days as like below,

    Dates_Count = CALCULATE(COUNT('Date'[Date Built]),'Date'[Date Built]>=TODAY()-7)
    please find the below screenshot FYR.

    DateSet:
    Output:
     
    Best Regards,
    @Mail2inba4

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can use the today function in a calculate like the following:

    Measure =
    CALCULATE (
        COUNT ( 'Table'[Date Built] );
        'Table'[Date Built]
            >= ( TODAY () - 7 )
    )

    Kind regards
    Joren Venema

    Data & Analytics Consultant
    If this reply solved your question be sure to mark this post as the solution to help others find the answer more easily. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi cottrera,


    Create a measure to count dates for the past 7 days as like below,

    Dates_Count = CALCULATE(COUNT('Date'[Date Built]),'Date'[Date Built]>=TODAY()-7)
    please find the below screenshot FYR.

    DateSet:
    Output:
     
    Best Regards,
    @Mail2inba4

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.