Forum Discussion
Countrows on weekly periods
- Anonymous6 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
Hi Mike_Mace,
I'd like to suggest you use year and weeknum to filter and calculated the records:
formual =
VAR currDate =
MAX ( Performance[Date] )
RETURN
CALCULATE (
COUNTROWS ( 'Entries table' ),
FILTER (
ALLSELECTED ( 'Entries table' ),
YEAR ( [Created] ) = YEAR ( currDate )
&& WEEKNUM ( [Created] ) = WEEKNUM ( currDate )
)
)
If the above not help, please provide more detailed information to help us clarify your requirement.
Regards,
Xiaoxin Sheng
- Mike_Mace6 years ago
Resolver I
Hi Anonymous ,
Attaching the pbix on a wetranfer link as my first message was not accurate enough to pass on the query.
I've removed the relationship between the two datasets and the original formula to calculate all the entries per said week (on performance dataset) seems to work BUT the value for the latest date is not calculated.
I've manually checked the numbers from the spreadsheet side for that week to be 864 but see on snip it is left empty.
Does formula need another filter?
I've crosschecked another two weeks by checking the number of entries from the spreadsheet manually and the numbers are correct
Entries /week column = CALCULATE(COUNTROWS('Entries table'), DATESINPERIOD('Entries table'[Created], Performance[Date], -7, DAY))
snip