Forum Discussion

Mariam1991's avatar
Mariam1991
Icon for Helper II rankHelper II
9 years ago
Solved

Cumulative sum by trimester

HI;

I need to calculate sum cumulative of sales by trimester , i calculate a meaure but it's doesn't work

Cumulative_sum=calculate(sum(table[sales]); filter(allselected('Date'); Date[trimester]=max(Date[trimester])))

  • Hi all;

    I have 2 tables sales and date , the rignt measure and it works correctly 

    cumulative_sum= calculate(sum(tableA[sales]);DATESYTD('Date'[Date]))

3 Replies

  • Hi there. Mmm... is a complicated case due to the columns and the rows are from the same field (date). Let's try this:

    Cumulative= CALCULATE (

        SUM ( SalesTable[sales]);

        FILTER (

            ALLSELECTED( SalesTable);

            SalesTable[Date] <= MAX ( SalesTable[Date] )

        )

    )

     

    If even this fails due to the issue I mention before, maybe playing with [Quarter] of dates can help.

     

    Regards,

  • Anonymous's avatar
    Anonymous
    Not applicable

    Mariam1991,

    Could you please share raw data of your original tables?

    I make a test using the following sample table.


    Create a measure using the following DAX and then create a Matrix visual.
    cum = CALCULATE(SUM(Table2[sales]),FILTER(ALL(Table2[date]),Table2[date]<=MAX(Table2[date])))


    Regards,
    Lydia Zhang

    • Mariam1991's avatar
      Mariam1991
      Icon for Helper II rankHelper II

      Hi all;

      I have 2 tables sales and date , the rignt measure and it works correctly 

      cumulative_sum= calculate(sum(tableA[sales]);DATESYTD('Date'[Date]))