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
Schwinn123
Helper I
Helper I

How to achieve the SUMIF in DAX. Condition just contains some string

How to achieve the SUMIF in DAX. Condition just contains some string.  

For example,  =SUMIF($C:$C,"*SPARE PART*",$F:$F)  

How to Describe this in DAX?

 

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a sample to test:

60.PNG

For example, if you want to sum the values that [String] contains "AB", please try to create this column first:

 

Column = IF(FIND("AB",'Table'[String],1,0)<>0,1,0)

 

Then try this measure:

 

Measure = CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Column]=1))

 

The result shows:

61.PNG

Above is the function By DAX like the SUMIF in Excel.

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

2 REPLIES 2
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a sample to test:

60.PNG

For example, if you want to sum the values that [String] contains "AB", please try to create this column first:

 

Column = IF(FIND("AB",'Table'[String],1,0)<>0,1,0)

 

Then try this measure:

 

Measure = CALCULATE(SUM('Table'[Value]),FILTER('Table','Table'[Column]=1))

 

The result shows:

61.PNG

Above is the function By DAX like the SUMIF in Excel.

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

TomMartens
Super User
Super User

Hey @Schwinn123 ,

 

you can use a measure like this:

SUMX(
	VALUES('<tablename>'[name of the column in C])
	, IF(
		FIND(...)
		, CALCULATE(SUM('<tablename>'[name of the column in F]))
		, BLANK()
)

Here you will find an explanation to all the DAX functions: https://dax.guide/

 

Hopefully, this gets you started.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.

April Fabric Community Update

Fabric Community Update - April 2024

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