Forum Discussion

sparker95's avatar
sparker95
Frequent Visitor
2 years ago
Solved

Avoiding repetition with calculations

I have a report that at the start I selected a Primary Project and then I will compare this with other projects throughout. I have to create measures that give a value for the selected 'Primary Project' e.g 

£/ft2 GIA Primary Project =
VAR PrimaryProjectID = SELECTEDVALUE('Primary Project'[ID])

RETURN
CALCULATE(
    [£/ft2 GIA]
    , ALL(Project)
    , Project[ID] = PrimaryProjectID
)
I then also need to compare that same measure with an average of the others e.g

Average £/ft2 GIA =
VAR PrimaryProjectID = SELECTEDVALUE('Primary Project'[ID])
VAR A = [£/ft2 GIA]
RETURN
CALCULATE(
    AVERAGEX(
        VALUES(Project[ID]),
        A
    ),
    ALL(Project),
    Project[ID] <> PrimaryProjectID

I need to do this throughout with lots of metrics in reports, which means for each metrics I need to create 3 version of the same calculation. Is there a simpler way of doing this to avoid repetition and having lots of measures.
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi sparker95 ,

    I create two tables as you mentioned.

    Then I create a measure and here is the DAX code.

     

    Measure = SUM(Projects[£/ft2 GIA])

     

    Just as Greg_Deckler said, you can use Calculation group.

    So you can use it in anywhere you want.

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi sparker95 ,

    I create two tables as you mentioned.

    Then I create a measure and here is the DAX code.

     

    Measure = SUM(Projects[£/ft2 GIA])

     

    Just as Greg_Deckler said, you can use Calculation group.

    So you can use it in anywhere you want.

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.