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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ACT_
New Member

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
Resident Rockstar
Resident Rockstar

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.