Forum Discussion

vijaykumarj19's avatar
vijaykumarj19
Icon for Microsoft Employee rankMicrosoft Employee
6 years ago
Solved

Divide Rows of same columns with row in same column

descv1v2v3v4v5
a1022324323
b2232646643
c2143433454
d3232435456
Z200300400500600

 

I want to divide a,b,c,d rows by z to calculate percentage

 

output should be

descv1v2v3v4v5
aav1/zv1av2/zv2   
bbv1/zv1bv2/zv2   
ccv1/zv1cv2/zv2   
ddv1/zv1dv2/zv2   

 

like i have multiple columns(v6,v7.......)

Need percentage 

  • Here is one way to do it.  Just highlight first column and "Unpivot Other Columns", load that table and it will look like the below.

    Then use this DAX expression in a calculated column. 

    Divide =
    DIVIDE (
    vZTable[Value],
    CALCULATE (
    MIN ( vZTable[Value] ),
    ALLEXCEPT ( vZTable, vZTable[vNumber] ),
    vZTable[desc] = "Z"
    )
    )

    For the measure version, just wrap the first Divide expression with SELECTEDVALUE() and use it in a table visual with the desc and vNumber columns.

     

    If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat

3 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    Here is one way to do it.  Just highlight first column and "Unpivot Other Columns", load that table and it will look like the below.

    Then use this DAX expression in a calculated column. 

    Divide =
    DIVIDE (
    vZTable[Value],
    CALCULATE (
    MIN ( vZTable[Value] ),
    ALLEXCEPT ( vZTable, vZTable[vNumber] ),
    vZTable[desc] = "Z"
    )
    )

    For the measure version, just wrap the first Divide expression with SELECTEDVALUE() and use it in a table visual with the desc and vNumber columns.

     

    If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

    Regards,

    Pat