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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ACT_
Regular Visitor

Summary Table (Average with Condition "Contains")

Hi!

I've been working on a project and now I need to create a Summary Table. The main Table has a column named "Product" where are the products that each worker has made (comma separated) and the column "Proccess Time" shows the respective time of production.

 

I need to create a Summary Table, like the Excel image below, that calculates the average proccess time if value on column "Product" contains the string in column "Contains". I have tried to create a Table in PowerBI using the functions "Calculate"+"Filter"+"Related", and even using "Summarize", but it didn't work correctly. Could someone help me to understand how can i make this Summary Table?

 

ACT__2-1711815847961.png

 


PS.: in Excel I have used "Avarageif" function to obtain the Summary Table.

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@ACT_ 

Create a table as follows. Assumed you have a table called 'Contain Table' with Contain text.

 

ADDCOLUMNS(
	'Contain Table',
	"Avg", 
		VAR __Txt = 'Contain Table'[Contains]
		VAR __TxtFilter = FILTER( ALLNOBLANKROW( Table03[Product] ) , CONTAINSSTRING( Table03[Product] , __Txt ) )	
		VAR __Result = CALCULATE( AVERAGE( Table03[Proccess Time] ) , __TxtFilter )
		RETURN
			__Result
)

 

 

Fowmy_0-1711818914044.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
AmiraBedh
Super User
Super User

I started by splitting your data based on the column Product into rows with comma delimiter :

AmiraBedh_0-1711819437665.png

Then I removed the additional spaces :

AmiraBedh_2-1711819668053.png

Then I extracted the product alpha-number like X1, X2...

AmiraBedh_3-1711819775243.png

 

I created a DAX measure based in the formatted table:

 

 

AverageTimeX = CALCULATE(AVERAGE(MyTable[Process Time]), FILTER(MyTable, CONTAINSSTRING(MyTable[ProductName], "X")))

 

 

 

AmiraBedh_4-1711820960879.png

 

But I fail how you are calculating the average for X, Y and Z


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
Fowmy
Super User
Super User

@ACT_ 

Create a table as follows. Assumed you have a table called 'Contain Table' with Contain text.

 

ADDCOLUMNS(
	'Contain Table',
	"Avg", 
		VAR __Txt = 'Contain Table'[Contains]
		VAR __TxtFilter = FILTER( ALLNOBLANKROW( Table03[Product] ) , CONTAINSSTRING( Table03[Product] , __Txt ) )	
		VAR __Result = CALCULATE( AVERAGE( Table03[Proccess Time] ) , __TxtFilter )
		RETURN
			__Result
)

 

 

Fowmy_0-1711818914044.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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