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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
vincentakatoh
Helper IV
Helper IV

Measure multply rows in matrix

Hi, 

New to Power BI. Will like to create a new measure to calculate yield rate (%)

 

1) Line 1 Yield = S1 Yield * S2 Yield 

2) Station Yield = Count P/(CountP+ CountF)*100%

 

Question: How to do you write the DAX equivalent for above.

 

AreaLinestationtest results
SMTLine1S1P
SMTLine1S1F
SMTLine1S1P
SMTLine1S2F
SMTLine1S2F
SMTLine1S2P

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vincentakatoh,

Firstly, duplicate your table in Query Editor, then pivot column and add a index column for this new table.
2.PNG3.PNG

Secondly, create new columns as follows.

Yieldpertestresult = 'newtable'[S1]/('newtable'[S1]+'newtable'[S2]+'newtable'[S4])

Lineyield = IF('newtable'[Line]=LOOKUPVALUE('newtable'[Line],'newtable'[Index],'newtable'[Index]-1),'newtable'[Yieldpertestresult]*LOOKUPVALUE('newtable'[Yieldpertestresult],'newtable'[Index],'newtable'[Index]-1),0)

Thirdly, create a table visual as shown in the following screenshot.
1.PNG


Thanks,
Lydia Zhang

View solution in original post

9 REPLIES 9
Greg_Deckler
Community Champion
Community Champion

I do not see anything numeric in your data that would allow you to multiply 2 things together. I'm assuming that CountP would be the count of all things with test results P and similar CountF. Those you could do with something like:

 

CountP = CALCULATE(COUNTA([Line]),FILTER(table,[test results]="P"))

CountF = CALCULATE(COUNTA([Line]),FILTER(table,[test results]="F"))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler thanks for the prompt reply. 

 

In my example

Station 1 yield = 2(P+P)/3(P+F+P)= 66%

Station 2 yield = 1 (P)/3 (F+F+P)= 33%

Line 1 yield = Station 1 Yield x Station 2 Yield =66% * 33% = 0.21%

 

I have added 3 measure

- Count P = COUNTROWS(FILTER('Data', [TestResult] = ("P")))

- Count F = COUNTROWS(FILTER('Data', [TestResult] = ("P")))

- Yield = [CountP/([CountP+[CountF)]

 

Que: How do I write a DAX to calculate the Line 1 Yield?

 

Station 1CountPCountFYield
S12167%
S11233%
Line1  22%

To add, 

Power BI currently calculates Line 1 yield as below, summing all CountP and CountF

 

Station 1CountPCountFYield
Line13350%

 

The Line1 yield i'm trying to calculate = Line 1 yield = Station 1 Yield x Station 2 Yield =67% * 33%= 22%

 Station1 YieldStation2 YieldLine 1 Yield
Line167%33%22%

 

Thanks. 

Anonymous
Not applicable

Hi @vincentakatoh,

In your scenario, create the another three measures(replace Table2 with you own table) and Matrix visual.

Station1 Yield = CALCULATE([Yield],FILTER(Table2,Table2[station]="S1"))
Station2 Yield = CALCULATE([Yield],FILTER(Table2,Table2[station]="S2"))
Line 1 Yield = [Station1 Yield]*[Station2 Yield]
1.PNG

 

 

Thanks,
Lydia Zhang

Hi Lydia, 

Thanks. 

 

The actual data has thousand of lines. There are many multiple lines and multiple stations (unknow number). 

 

Is there a DAX formula that I can use to calculate the station and line yield dynamically based on filter. 

 

PS. Love this forum and the amazingly prompt answer. Great for Power BI dummy like me. 

 

 

Added more rows to better reflect actual data

 

1) Staiton yield = CountP/(CountP+CountF)

2) Line yield = station yield * station yield

 

AreaLinestationtest results
SMTLine1S1P
SMTLine1S1F
SMTLine1S1P
SMTLine1S2F
SMTLine1S2F
SMTLine1S2P
SMTLine2S1P
SMTLine2S1F
SMTLine2S1P
SMTLine2S2F
SMTLine2S2F
SMTLine2S2P
SMTLine3S1P
SMTLine3S1F
SMTLine3S1P
SMTLine3S4F
SMTLine3S4F
SMTLine3S4P
Anonymous
Not applicable

Hi @vincentakatoh,

Firstly, duplicate your table in Query Editor, then pivot column and add a index column for this new table.
2.PNG3.PNG

Secondly, create new columns as follows.

Yieldpertestresult = 'newtable'[S1]/('newtable'[S1]+'newtable'[S2]+'newtable'[S4])

Lineyield = IF('newtable'[Line]=LOOKUPVALUE('newtable'[Line],'newtable'[Index],'newtable'[Index]-1),'newtable'[Yieldpertestresult]*LOOKUPVALUE('newtable'[Yieldpertestresult],'newtable'[Index],'newtable'[Index]-1),0)

Thirdly, create a table visual as shown in the following screenshot.
1.PNG


Thanks,
Lydia Zhang

Hi Lydia, 

Thanks and appreciate the patience.

 

1) I encountered below error in 2nd step, add column for "yieldpertestresults". 


2017-04-06 22_02_11-Untitled - Query Editor.png

 

2) Below requires "S1, S2, S4" to be written. But in actual data, there are many station names (S1, S2, S3... S50). Anyway to use "station" vs "S1, S2, S4... " in the formula. 

 

Yieldpertestresult = 'newtable'[S1]/('newtable'[S1]+'newtable'[S2]+'newtable'[S4])

 

3) The data is also retrieve from a folder with mutilple excel sheets. One sheet for a different date

Hi Lydia, 

 

Thanks! Managed to calculate line yield. Was adding column in Edit Query. Should have done it outside. 

 

Question: Below requires "S1, S2, S4" to be written. But in actual data, there are many station names (S1, S2, S3... S50). Anyway to use "station" vs "S1, S2, S4... " in the formula. 

 

Yieldpertestresult = 'newtable'[S1]/('newtable'[S1]+'newtable'[S2]+'newtable'[S4])

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.