Forum Discussion

jderekc's avatar
jderekc
Helper IV
9 years ago
Solved

Alternate Calculations in Matrix

Hi all,   I am curious if there is a way to accomplish what I am trying to do.  Please bear with me...  I have a matrix that has limited interactive options (search by vendor or product type).  Thi...
  • Anonymous's avatar
    Anonymous
    9 years ago

    Hi jderekc,

     

    You can refer to below formula to use row label to switch calculate formula:

    % & Diff = 
    var currentType=LASTNONBLANK('Sample'[Type],[Type])
    return
    SWITCH(currentType,"D",SUM('Sample'[Net Sales])-SUM('Sample'[Gross profit]),FORMAT(DIVIDE(SUM('Sample'[Gross profit]), SUM('Sample'[Net Sales]),0),"percent"))

     

    Source table:

     

    Notice: Type A,B,C calculate percent, Type D calculate diff.

     

     

    Regards,

    Xiaoxin Sheng