Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
SimaoCoimbra
Frequent Visitor

Cumulative Sum by Year and Month or Only by Month when no Year is selected

Hello everyone,

I have a measure that calculates the monthly value, and then I have another measure that calculates the accumulated total, which is working correctly

Image_With_Filter.png

Cumulative Measure:

Valor_OIL_Acumul =
IF (
MIN ( 'date'[Month Number] )
<= CALCULATE ( MAX ( table[Date] ), ALL ( table) ),
CALCULATE (
        [Month Total Measure],
       FILTER (
        ALL ( 'date' ),
         'date'[Year] = MAX ( 'date'[Year] )
         && 'date'[Date] < MAX ( 'date'[Date] )
                                    )
                 )
)
 
 
The problem exists when no year is selected:
 
Image_Without_Filter.png
 
I would like the final result to be the following:   12 075.214 
                                                                              41 779.905
                                                                                ....
 
 
Thank you very much in advance,
Simao Coimbra
1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @SimaoCoimbra 

 

According to your description, The idea is to add a column to the virtual table. This column is the column equivalently converted from [Month Total Measure], and then calculate the cumulative value of this new column on the basis of this table.
Like this:

measure=
var t =
summarize(
   All(table),
   table[month number],
   "Month Total",
   xxx(Convert Month Total Measure to Month Total column)
)
var tab = 
addcolumns(
   t,
   "Cumu",
   sumx(
      filter(
          t,
          [month number]<=earlier(table[month number])
      ),
      [Month Total]   
   )
)
return
sumx(
  filter(
      tab,
      [month number] = selectedvalue[month number]
  ),
  [Cumu]
)

If it doesn’t solve your problem, please share some sample data and feel free to ask me.

 

Best Regards

Janey Guo

 

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

View solution in original post

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hi, @SimaoCoimbra 

 

According to your description, The idea is to add a column to the virtual table. This column is the column equivalently converted from [Month Total Measure], and then calculate the cumulative value of this new column on the basis of this table.
Like this:

measure=
var t =
summarize(
   All(table),
   table[month number],
   "Month Total",
   xxx(Convert Month Total Measure to Month Total column)
)
var tab = 
addcolumns(
   t,
   "Cumu",
   sumx(
      filter(
          t,
          [month number]<=earlier(table[month number])
      ),
      [Month Total]   
   )
)
return
sumx(
  filter(
      tab,
      [month number] = selectedvalue[month number]
  ),
  [Cumu]
)

If it doesn’t solve your problem, please share some sample data and feel free to ask me.

 

Best Regards

Janey Guo

 

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

Thank you very much @v-janeyg-msft. You've saved my week!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.