Forum Discussion

vincentakatoh's avatar
vincentakatoh
Helper IV
9 years ago
Solved

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

 

  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi vincentakatoh,

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


    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.



    Thanks,
    Lydia Zhang

9 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    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"))
    • vincentakatoh's avatar
      vincentakatoh
      Helper IV

      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%
      • vincentakatoh's avatar
        vincentakatoh
        Helper IV

        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.