Forum Discussion

geirselvag's avatar
geirselvag
Frequent Visitor
1 year ago
Solved

DAX help - distributed sum

Hello folks,   The DAX requirements I'm faced with is include to be able to distribute project cost (or settlement) to other project based on precentage. The basis for DAX is two tables one dim_WBS...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi geirselvag 

     

    Sorry for the late reply.

    Try to update the measure with the following DAX:

    Cost_Distributed_Measure = 
    SUMX(
        fact_COST,
        VAR CurrentWBS = fact_COST[WBS]
        VAR CurrentCOST = fact_COST[Cost]
        VAR NewWBS = IF(
            ISBLANK(LOOKUPVALUE(dim_WBS[Settlement_WBS], dim_WBS[WBS], CurrentWBS)),
            CurrentWBS,
            LOOKUPVALUE(dim_WBS[Settlement_WBS], dim_WBS[WBS], CurrentWBS)
        )
        VAR OriginalCost = CALCULATE(
            SUM(fact_COST[Cost]),
            fact_COST[WBS] = NewWBS,
            REMOVEFILTERS(fact_COST)
        )
        VAR Distributed = OriginalCost * LOOKUPVALUE(dim_WBS[Percent], dim_WBS[WBS], CurrentWBS)
        RETURN
        IF(ISBLANK(Distributed), 0, Distributed + CurrentCOST)
    )

     

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

  • geirselvag's avatar
    geirselvag
    1 year ago

    This is excellent work.
    Thank you!

    Kind regards,
    Geir