Forum Discussion

Giancarlo's avatar
Giancarlo
Regular Visitor
7 years ago
Solved

search function dynamic

Hello,

 

I need to calculate someting like

plannedDayQty = CALCULATE(COUNTROWS(day);SEARCH("2";day[weekPlan];;0)) 

how can I enter the dynamic day value with the report date filter?
example:
plannedDayQty = CALCULATE(COUNTROWS(day);SEARCH('calendar'[DayOfWeekNumber];day[weekPlan];;0))
day[weekPlan] contains multiple data like "2,4" or "2,3,4,5" etc...
  • Hi Giancarlo,

     

    Try this one, please.

     

    plannedDayQty =
    VAR selected =
        SELECTEDVALUE ( 'calendar'[DayOfWeekNumber] )
    RETURN
        CALCULATE ( COUNTROWS ( day ); SEARCH ( selected; day[weekPlan];; 0 ) )
    

     

    Best Regards,

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Ciao Giancarlo
    If understand correctly you have to make the "2" in the SEARCH dynamic?
    If so create a table with your values, put that in a slicer and use SELECTEDVALUE(Yourtableslicer[column]) in place of the 2.

     

    unless i haven't understood ...

    • Giancarlo's avatar
      Giancarlo
      Regular Visitor

      Thanks but...

      A 'SELECTEDVALUE' function was used in a True / False expression used as a table filter expression. This is not allowed.

       

      I used

      plannedDayQty = CALCULATE(COUNTROWS(day);SEARCH(SELECTEDVALUE('calendar'[DayOfWeekNumber]);day[weekPlan];;0))
      • v-jiascu-msft's avatar
        v-jiascu-msft
        Microsoft Employee

        Hi Giancarlo,

         

        Try this one, please.

         

        plannedDayQty =
        VAR selected =
            SELECTEDVALUE ( 'calendar'[DayOfWeekNumber] )
        RETURN
            CALCULATE ( COUNTROWS ( day ); SEARCH ( selected; day[weekPlan];; 0 ) )
        

         

        Best Regards,