Forum Discussion

s_mccafferty's avatar
s_mccafferty
Frequent Visitor
7 years ago
Solved

DAX: Calculate Percentages

I have a data model similar to the below:

Building Occupier Area
building 1 occupier1 10000
building 1 occupier 2 15000
building 2 occupier 3 10000
building 3 occupier 4 10000
building 3 occupier 5 20000

So essentially, any building can have one or more occupiers. What I am wanting to work out is the percentage each occupier has for the building they occupy. So in the above example, occupier 1 has 10000 sqft of an 25000 sqft building, so they occupy 40% of building 1. How can I calculate that across the entire dataset.

  • Hi s_mccafferty ,

     

    Here we can create a measure to work on it.

     

    Measure =
    VAR oc =
        CALCULATE ( SUM ( Table1[area] ) )
    VAR al =
        CALCULATE ( SUM ( Table1[area] ), ALL ( Table1 ), VALUES ( Table1[Building] ) )
    RETURN
        DIVIDE ( oc, al )
    

     

    Pbix as attached.

     

    Regards,

    Frank

3 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Icon for Community Support rankCommunity Support

    Hi s_mccafferty ,

     

    Here we can create a measure to work on it.

     

    Measure =
    VAR oc =
        CALCULATE ( SUM ( Table1[area] ) )
    VAR al =
        CALCULATE ( SUM ( Table1[area] ), ALL ( Table1 ), VALUES ( Table1[Building] ) )
    RETURN
        DIVIDE ( oc, al )
    

     

    Pbix as attached.

     

    Regards,

    Frank