Forum Discussion

Mike_Mace's avatar
Mike_Mace
Resolver I
6 years ago
Solved

Countrows on weekly periods

Happy August-ing developers Some help from whom can lend an ear   I have table A. showing entries data by created date I have table B. showing historic performance per specific dates The two dat...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Mike_Mace,

    My formula is a measure please create a measure and copy the code into measure expression to use it:

    Entries New/week test 2= 
    VAR currDate =
        MAX ( 'Performance Table'[Dates] )
    RETURN
        CALCULATE (
            COUNTROWS ( 'Entries Table' ),
            FILTER (
                ALLSELECTED ( 'Entries Table'),
                YEAR ( [Created]) = YEAR ( currDate )
                    && WEEKNUM ( [Created] ) = WEEKNUM ( currDate )
            )
        )

    If you want a calculated column version, you can try to use following calculated column formula: (Notice: calculated column/table did not dynamic changes based on filters/slicers)

    Entries New/week test 2 =
    CALCULATE (
        COUNTROWS ( 'Entries Table' ),
        FILTER (
            ALLSELECTED ( 'Entries Table' ),
            YEAR ( [Created] ) = YEAR ( EARLIER ( 'Performance Table'[Dates] ) )
                && WEEKNUM ( [Created] ) = WEEKNUM ( EARLIER ( 'Performance Table'[Dates] ) )
        )
    )
    

    Regards,

    Xiaoxin Sheng