Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Giancarlo
Regular Visitor

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...
1 ACCEPTED SOLUTION

Hi @Giancarlo,

 

Try this one, please.

 

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

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
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 ...

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))

Hi @Giancarlo,

 

Try this one, please.

 

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

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

If you have such an error, don't use calculate(measure, rule) but calculate(measure, filter(table, rule))

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.