Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Same calculations on multiple columns

  I am new to Power BI desktop and I am trying to conceptually understand the best way to tackle this problem. So I have a table that looks like this: Index FIFO2_1 FIFO2_2 FIFO2_3 FI...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Ashish_MathurThanks Ashish, I was actually able to solve the problem by pivoting the table in the following way. And then working with rows instead of columns.

    Index FIFO2 Value

    0FIFO2_10.097
    0FIFO2_20.096
    0FIFO2_30.101
    0FIFO2_40.096
    .........
    30FIFO2_60.126
    30FIFO2_70.064


    Changing the DAX to:

     

    AverageBetween400and440 = 
      CALCULATE(
        AVERAGE('Table'[Value]),
        'Table'[Index] >= 15 && 'Table'[Index] <= 20
      )
    
    
    transformed_FIFI2 =  [AverageBetween400and440] - SUM('Table'[Value])
    
    
    Avg Last 10 Max = 
      var maxV = MAX('Table'[Value])
      var maxI = CALCULATE(MAX('Table'[Index]), 'Table'[Value] = maxV)  
      RETURN
        CALCULATE(
          AVERAGE('Table'[Value]),
          'Table'[Index] > maxI - 10 && 'Table'[Index] <= maxI 
        )