Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

COUNTROWS Duplicates Names with filter

Hi!

I'm currently stuck on this what i believe should be a simple endevour.

I am trying to count the duplicates Names within a table and i have a solution for that. Although, i want to count the duplicates from last week only.
Lets say i have week 24,25 & 26 data within my table. I only want to count the duplicates from week 25. Everything else should be blank or recieve zero value.

I've tried several ways but i still get values on all the weeks.
Help would be much appreciated!

-------------------------------------------------------------------------------------------------------------------------------------
Here is my working solution for all weeks:

Count Names 1 =
Var Names = [Name]
RETURN
CALCULATE(
COUNTROWS('Sheet1'),
all('Sheet1'),
'Sheet1'[Name] = Names
)

Here is my solution for highest week - 1 that doesn't seem to be working:

Count Names 2 =
var Names = Sheet1[Name]
var SelectedDate = MAX(Sheet1[Week])
var PreviousWeek = SelectedDate -1

RETURN

CALCULATE(
COUNTROWS('Sheet1'),
CALCULATETABLE(all('Sheet1')),
'Sheet1'[Name] = Names && 'Sheet1'[Week] = PreviousWeek
)



Kind Regards
D

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    Please remove the ALL() filter:

    New measure =
    var SelectedDate = MAXX(allselected(Sheet1), Sheet1[Week])
    var PreviousWeek = SelectedDate -1
    RETURN
    CALCULATE(
    COUNTROWS('Sheet1'),
    filter('Sheet1',
    'Sheet1'[Name] = max('Sheet1'[Name] ) && 'Sheet1'[Week] = PreviousWeek
    )

     

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

6 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 
    Would you please share a screenshot that illustrates the expected result. Thank you

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please remove the ALL() filter:

    New measure =
    var SelectedDate = MAXX(allselected(Sheet1), Sheet1[Week])
    var PreviousWeek = SelectedDate -1
    RETURN
    CALCULATE(
    COUNTROWS('Sheet1'),
    filter('Sheet1',
    'Sheet1'[Name] = max('Sheet1'[Name] ) && 'Sheet1'[Week] = PreviousWeek
    )

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi and thank you for your response!
      Worked like a charm. Much obliged!