Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Cumulative_Total based on QM-lot

Hi All,

 

I'm stcuk with something. I have a table which contains Mrp_Elements, QI, Quantities.

So, here I have a column that has a QI column which is same for all the MRP_elements and then there is a Quantities column that changes for every MRP_element. Now I want to achieve a column i.e. Cumulative_Total in such a way that it takes the cumulative only for QM-Lot(MRP_Element).

 

MRP_ElementsQIQuantities
STO20050
STO20025
QM-lot200125
STO20050
QM-lot20075
STO20050
QM-lot20020

I'll elaborate the query for better understanding. Now the other column that I want to achieve will be  in the following way:

When the MRP_element is STO or anything else the new column will give the QI as the result i.e. for MRP_element: STO, QI =200, Quantities = 50, Cum_total = 200. Where as if the Mrp_element = QM-lot,QI=200, Quantities = 125, Cum_total = 200-125=75 and the achieved cum_total should appear the same until the next QM-lot.  for the next QM-lot the total would be 75-75 = 0, and so on. 

I have attached the table for better understanding.

 

 

MRP_ElementsQIQuantitiesCum_Total
STO20050200
STO20025200
QM-lot20012575
STO2005075
QM-lot200750
STO200500
QM-lot20020-20

 

Would be really helpful if anyone helps me out with this. I'm badly stuck at this.

I don't mind whether it is a measure or a calculated column.

 

Hope you understood what I tried to explain.

 

Thanks in advance.

 

amitchandak Ashish_Mathur Fowmy Jihwan_Kim SpartaBI tamerj1 ChandeepChhabra Vahid-DM 

  • Hi Anonymous 
    I have added an index column using power query. Here is the smaple file with the solution https://we.tl/t-tfARCM9jCs

    Apologies for not including screenshots as I already consumed my limit of uploaded images but I can assure you it is working fine. The solution is based on a calculated column. Please let me know if you need a measure instead.

     

    Cum_Total = 
    VAR CurrentQI = Data[QI]
    VAR CurrentIndex = Data[Index]
    VAR PreviousQMlots = FILTER ( Data, Data[MRP_Elements] = "QM-lot" && Data[Index] <= CurrentIndex )
    VAR PreviousQMlotValues = SUMX ( PreviousQMlots, Data[Quantities] )
    RETURN
        CurrentQI - PreviousQMlotValues

     

    **Update

    Here is the code of the measure https://we.tl/t-OpH3iQQFZC

    Cum_Total Measure = 
    VAR CurrentQI = SUM ( Data[QI] )
    VAR CurrentIndex = SELECTEDVALUE ( Data[Index] )
    VAR PreviousQMlots = FILTER ( ALL ( Data ), Data[MRP_Elements] = "QM-lot" && Data[Index] <= CurrentIndex )
    VAR PreviousQMlotValues = SUMX ( PreviousQMlots, Data[Quantities] )
    RETURN
        CurrentQI - PreviousQMlotValues

     

     

4 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 
    I have added an index column using power query. Here is the smaple file with the solution https://we.tl/t-tfARCM9jCs

    Apologies for not including screenshots as I already consumed my limit of uploaded images but I can assure you it is working fine. The solution is based on a calculated column. Please let me know if you need a measure instead.

     

    Cum_Total = 
    VAR CurrentQI = Data[QI]
    VAR CurrentIndex = Data[Index]
    VAR PreviousQMlots = FILTER ( Data, Data[MRP_Elements] = "QM-lot" && Data[Index] <= CurrentIndex )
    VAR PreviousQMlotValues = SUMX ( PreviousQMlots, Data[Quantities] )
    RETURN
        CurrentQI - PreviousQMlotValues

     

    **Update

    Here is the code of the measure https://we.tl/t-OpH3iQQFZC

    Cum_Total Measure = 
    VAR CurrentQI = SUM ( Data[QI] )
    VAR CurrentIndex = SELECTEDVALUE ( Data[Index] )
    VAR PreviousQMlots = FILTER ( ALL ( Data ), Data[MRP_Elements] = "QM-lot" && Data[Index] <= CurrentIndex )
    VAR PreviousQMlotValues = SUMX ( PreviousQMlots, Data[Quantities] )
    RETURN
        CurrentQI - PreviousQMlotValues

     

     

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 
    Do you have an index, date or any unique numeric column?

    • Anonymous's avatar
      Anonymous
      Not applicable

      I have a date column included in thte table. I have not mentioned in this samle table that i have sent you

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        Anonymous 
        If it is unique just replace the index column in the code with the date column.