Forum Discussion

timward10's avatar
timward10
Helper II
1 year ago
Solved

Formula

Hi, 

 

I am trying to pull back the count of the account in another table, but also include a filter to select the date. 

 

Currently for the count, it is just bringing back a total instead of it being related to the 'name' column, this is before I have tried to add in the date name. The reference for the date name is year month in the event table.  

 

Can anyone help please? 

 

Thanks 

 

 

  • johnt75's avatar
    johnt75
    1 year ago

    You could use

    Jan'25 =
    CALCULATE (
        COUNTROWS ( Event ),
        FILTER (
            Event,
            Event[Account Name] = Test[Name]
                && Event[Activity Date (Month Year)] = "Jan 2025"
        )
    )
    

3 Replies

  • As you're creating a calculated column you have a row context, not a filter context, and SELECTEDVALUE only works in a filter context. Just replace the SELECTEDVALUE with Test[Name] and it should work.

  • Perfect, that has worked! 

     

    How do I add another filter into the same query to only return anything with a January date? I have a column in the event table called Month Year so I can reference that. 

     

    Using the below but it won't work with the second part of the filter. 

     

    Jan'25 = CALCULATE(
        COUNTROWS(Event),
        FILTER(Event,Event[Account Name]
        =(Test[Name],
        Event,Event[Activity Date (Month Year)]
        ="Jan 2025")))

     

    Thanks!

    • johnt75's avatar
      johnt75
      Super User

      You could use

      Jan'25 =
      CALCULATE (
          COUNTROWS ( Event ),
          FILTER (
              Event,
              Event[Account Name] = Test[Name]
                  && Event[Activity Date (Month Year)] = "Jan 2025"
          )
      )