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
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
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.