Forum Discussion

Ritaf's avatar
Ritaf
Responsive Resident
3 years ago
Solved

Aggregation for category which doesn't appear at visual

Hi there,
I am trying to calculate the sum by category as I won't use this category in my visual, so I can't do it with :

Test= CALCULATE( sum('Table'[score]),ALLEXCEPT(table,'table'[abc_item_ID])).
Could this be accomplished without a calculated column?
Thanks a lot, Rita

 
  • Hi Ritaf1983 ,

    try this measure

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

8 Replies

  • Hi , could you please send us a sample table and your expected result?

    • Ritaf's avatar
      Ritaf
      Responsive Resident

      Hello,
      I have attached a picture of the data and the expected result.
      For every OrdersCustomerItemId, I need to calculate the sum of POunitsQuantity without using OrdersCustomerItemId in the visual.
      Right now I am using a calculated column with an earlier function, and I am wondering if there is a better way to accomplish this.
      Thank you, Rita

       

    • Ritaf1983's avatar
      Ritaf1983
      Super User

      Thanks for your assistance.
      Are you sure that your solution is better than the calculated column I created: 

      QTYbyCorder = sumx(filter('factOrdersPurchase',factOrdersPurchase[OrdersCustomerItemId]=EARLIER(factOrdersPurchase[OrdersCustomerItemId])),'factOrdersPurchase'[QTY])
      Since this measure is one of many in this report, I don't need another table. However, I know that earlier is a very wasteful function, so I wondered if there was a way to calculate it with a measure using a virtual table.
      • mangaus1111's avatar
        mangaus1111
        Solution Sage

        Hi Ritaf1983 ,

        try this measure

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Ritaf ,

     

    Here are the steps you can follow:

    1. Create calculated table.

    Table 2 =
    SUMMARIZE('Table',[CusOrder],[PORDER],[Customer],[CatalogID],"TotalUnitsPurchased",
    SUMX(FILTER(ALL('Table'),'Table'[CatalogID]=EARLIER('Table'[CatalogID])),[POuniysQuantity]))

    2. Result:

    If you need pbix, please click here.

     

    Best Regards,

    Liu Yang

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

    • Ritaf1983's avatar
      Ritaf1983
      Super User

      Thanks for your assistance.
      Are you sure that your solution is better than the calculated column I created: 

      QTYbyCorder = sumx(filter('factOrdersPurchase',factOrdersPurchase[OrdersCustomerItemId]=EARLIER(factOrdersPurchase[OrdersCustomerItemId])),'factOrdersPurchase'[QTY])