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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Cumulative sum of sales in a financial year

Hi,

 

I am trying to include a column for cumulative sum in Power BI table visual. I have the fields of Financial Year, Month and date available also the sales made per month. Can anyone please help me out on how to include an additional column for a cumulative sum.

My power Bi is extracting data from analysis services (Tabular model)

 

Thanks,

Akshay

1 ACCEPTED SOLUTION
edhans
Super User
Super User

You need a date table to really do this correctly, though it is possible without one. This assumes your date table and field is Date[Date]. 

 

[Total Sales] below is simply SUM(Sales[Sales])

 

Cumulative Total = 
VAR CurrentDate = MAX(Sales[Date])
RETURN
CALCULATE(
    [Total Sales],
    REMOVEFILTERS('Date'[Date]),
    'Date'[Date] <= CurrentDate
)

20191107 07_59_25-Untitled - Power BI Desktop.png

 

A sample file is at this link.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

7 REPLIES 7
edhans
Super User
Super User

You need a date table to really do this correctly, though it is possible without one. This assumes your date table and field is Date[Date]. 

 

[Total Sales] below is simply SUM(Sales[Sales])

 

Cumulative Total = 
VAR CurrentDate = MAX(Sales[Date])
RETURN
CALCULATE(
    [Total Sales],
    REMOVEFILTERS('Date'[Date]),
    'Date'[Date] <= CurrentDate
)

20191107 07_59_25-Untitled - Power BI Desktop.png

 

A sample file is at this link.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Thanks @edhans  that worked out for me

Great. Glad to help!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
amitchandak
Super User
Super User

You have the option to show running a total of filed. You can use that. Also, you can create a quick measure for that.

 

Or try a formula like this

  
till date = 
Var _max_date = CALCULATE(maxx(all('Date'[Date Filer]),'Date'[Date Filer]))

Var   Sale_till_tody =CALCULATE(sum(Sales[Sales Amount]),filter(sales,Sales[Sales Date]<=maxx(Sales,Sales[Sales Date].[Date])))
Var   Sale_till_tody =CALCULATE(sum(Sales[Sales Amount]),Sales[Sales Date]<=_max_date)

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Anonymous
Not applicable

Hi Amit,

 

I applied the following formula in the measure:

CUMSUM =
Var _max_date = CALCULATE(maxx(all(ProjectStartDate[Date]),ProjectStartDate[Date]))

Var Sale_till_tody =CALCULATE(sum(FactProject[SalesPrice]),filter(ProjectStartDate,ProjectStartDate[Date<=MAXX(ProjectStartDate,ProjectStartDate[Date])))
Var Sale_till_tody =CALCULATE(sum(FactProject[SalesPrice]),ProjectStartDate[Date]<=_max_date)
 
It is throwing me the error for Var _max_date. Can you please let me know if I am putting some wrong values in as I am not familiar with DAX.
 
error.PNGAlso I tried using the built in quick measure for YTD total bu the filter value of date is not compatible with the Power BI date calendarformat.
 
 
 
 
 
jhartranft60
Advocate IV
Advocate IV

@Anonymous  Can you provide a quick mock-up with sample data so that we can better visualize what you're working with along with what you'd like the output to be?  

Anonymous
Not applicable

@jhartranft60  Please find the sample data below:

 

sample.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.