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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
NewPBI_user
Frequent Visitor

CONTAINSSTRING and SELECTEDVALUE in COUNT function

Hello,

 

I would like to ask for help as I cannot get over the problem. 

 

I have a matrix table with several measures. These measures are different calculations of contracts for different type of service. It is filtered by service name so I used CONTAINSSTRING for it. I would like to have in the table always only one type of the product and filter it by the slicer. But I do not know how to combine the CONTAINSSTRING and SELECTEDVALUE as it does not work. Below is my measure.

 

Measure =

        CALCULATE (
            COUNT( 'Orders'[_airtableRecordId] ),
            CONTAINSSTRING('Orders'[Product],SELECTEDVALUE('Garance product'[Column 1])),
            'Orders'[State] = "Fakturace"  || 'Orders'[State] = "Active",
            USERELATIONSHIP ( 'Calendar'[Date], 'Orders'[Uhrazeno] ),
            'Orders'[Uhrazeno] <> BLANK ()
)
 
If I replace SELECTEDVALUE('Garance product'[Column 1]) by the string f.e. "12M NEO", it works. 
 
Thanks in advace.
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Measure =
var s = SELECTEDVALUE('Garance product'[Column 1])
RETURN CALCULATE (
            COUNT( 'Orders'[_airtableRecordId] ),
            CONTAINSSTRING('Orders'[Product],s),
            'Orders'[State] IN { "Fakturace" , "Active"},
            USERELATIONSHIP ( 'Calendar'[Date], 'Orders'[Uhrazeno] )
)

View solution in original post

2 REPLIES 2
v-xuxinyi-msft
Community Support
Community Support

Hi @NewPBI_user 

 

First of all, thanks to @lbendlin  for the quick and efficient reply.

 

If your problem is not solved yet, you can also try to use MAX to replace SELECTEDVALUE.

 

Best Regards,
Yulia Xu

 

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

lbendlin
Super User
Super User

Measure =
var s = SELECTEDVALUE('Garance product'[Column 1])
RETURN CALCULATE (
            COUNT( 'Orders'[_airtableRecordId] ),
            CONTAINSSTRING('Orders'[Product],s),
            'Orders'[State] IN { "Fakturace" , "Active"},
            USERELATIONSHIP ( 'Calendar'[Date], 'Orders'[Uhrazeno] )
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.