Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Measures Total Aggregation

Hello,   I need support please to prevent Measures from aggregating when summing the total. To simplify, consider the below example where each of the below is stored in a different PowerBI table an...
  • v-xiaotang's avatar
    v-xiaotang
    4 years ago

    Hi Anonymous 

    The reason for this error is obviously because the logic for calculating the above rows is still called when calculating the total row.

    -

    "the 3 columns come from different tables and each require some filtering to get these numbers "

    in this scenario, you can try the way below, and since it is not clear what key is used to connect your product table with other tables, I will first assume that they are related with product name. Of course, if it is another key, you can replace it later, the principle is the same.

    -

    create the measures

    (1) how to change [Total Due Volume] [Total Stocks]: 

    Total Due Volume = 
    var _eachrow= SUMX(FILTER(ALL(Due),Due[Products]=MIN(ProductsList[Products])), Due[Due Volume])
    var _totalrow= SUMX(ALL(Due),Due[Due Volume])
    return IF(HASONEVALUE(ProductsList[Products]),_eachrow,_totalrow)
    Total Stocks = 
    var _eachrow= SUMX(FILTER(ALL(Stocks),Stocks[Products]=MIN(ProductsList[Products])), Stocks[Stocks])
    var _totalrow= SUMX(ALL(Stocks),Stocks[Stocks])
    return IF(HASONEVALUE(ProductsList[Products]),_eachrow,_totalrow)

    (2) how to change [Missing Volume]: 

    Missing Volume 1 = IF ( [Total Due Volume] - [Total Stocks] < 0, 0, [Total Due Volume] - [Total Stocks] )
    Missing Volume 2 = SUMX(ProductsList,[Missing Volume 1])

    then put Missing Volume 2 into the visual.

    result

     

    Best Regards,

    Community Support Team _Tang

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