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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Using CONTAINS to filter a column

Hi All
 
I am trying to sum a column of $ values with a filter being applied to 2 other columns. 
e.g., I want to sum the sales revenue column when the Intake column CONTAINS the word Intensive and the student booking date is greater than Jun 21. 
Below is what I have but it isn't bringing any values through. 
I have read a few posts and tried a few different things but still no luck. 
Any assistance is greatly appreciated. 
 
Sales Revenue Intensive only > Jun21 =
CALCULATE (
SUM ( 'Sales Reports'[Sales Revenue] ),
CONTAINSSTRING('Sales Reports'[Intake],"Intensive"),
'Sales Reports'[Student Booking Date] > DATE ( 2021, 5, 31 )
)
 
Cheers
Karen
1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

You measure is correct and works well.

I checked that with sample data and resualt for >Jun21 and >Jul21 are as below:

VahidDM_1-1629173590005.png

VahidDM_2-1629173728489.png

 

 

The measure @amitchandak shared has more advantages for you as you can see that on the table.

Please share the data in the table format to be able to review that.

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos VahidDM_3-1629173792221.png !!

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Anonymous 

 

You measure is correct and works well.

I checked that with sample data and resualt for >Jun21 and >Jul21 are as below:

VahidDM_1-1629173590005.png

VahidDM_2-1629173728489.png

 

 

The measure @amitchandak shared has more advantages for you as you can see that on the table.

Please share the data in the table format to be able to review that.

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos VahidDM_3-1629173792221.png !!

amitchandak
Super User
Super User

@Anonymous , Try with small change

 

CALCULATE (
SUM ( 'Sales Reports'[Sales Revenue] ),
filter('Sales Reports', CONTAINSSTRING('Sales Reports'[Intake],"Intensive") &&
'Sales Reports'[Student Booking Date] > DATE ( 2021, 5, 31 )
))

 

 

or

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

@VahidDM Thank you. I re checked my measure and it appears that I had mysteriously put a comma somewhere that shouldn't have been there. 😞 Apologies for this. Thank you for taking the time to check it. 

Cheers

Karen

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

Top Solution Authors