cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vishwasrajput66
New Member

Cumulative sum with calculated measure as field in power BI desktop

Hello,

I need to find the cumulative sum of my sales but my sales are not a direct field in the table. Its a measure created by me:-

 

Netsales =((CALCULATE(Sum(VW_RPT_SWGLINTD[NTAMVD_NEG]),VW_RPT_SWGLINTD[NTOFNO]>=445000,VW_RPT_SWGLINTD[NTOFNO]<=445999))+(CALCULATE(Sum(VW_RPT_SWGLINTD[NTAMVD_NEG]),VW_RPT_SWGLINTD[NTOFNO]=449000))+(CALCULATE(Sum(VW_RPT_SWGLINTD[NTAMVD_NEG]),VW_RPT_SWGLINTD[NTOFNO]=450000))+(CALCULATE(Sum(VW_RPT_SWGLINTD[NTAMVD_NEG]),VW_RPT_SWGLINTD[NTOFNO]>=448100,VW_RPT_SWGLINTD[NTOFNO]<=448999))+(CALCULATE(Sum(VW_RPT_SWGLINTD[NTAMVD_NEG]),VW_RPT_SWGLINTD[NTOFNO]>=451000,VW_RPT_SWGLINTD[NTOFNO]<=451999)))

 

Now I want to use this Net sales measure to get the cumulative sales. I tried:-

 

Running Net sales = calculate([Netsales]),filter(all(VW_RPT_SWGLINTD),VW_RPT_SWGLINTD[Date Picker <=max(VW_RPT_SWGLINTD[Date Picker])))

 

But it doesn't work. It just gave the same value as the NetSales. I cannot take Sum([Netsales]) as Netsales is a measure and it gives an error. I need some way to find the sum of a measure that I created. I also tried using the calculated column but it doesn't work either.

 

1 ACCEPTED SOLUTION

Hi @vishwasrajput66 ,

 

Please try this.

 

Running Net sales = 
SUMX(
    FILTER(
        ALL(VW_RPT_SWGLINTD),
       [Date Picker] <= MAX([Date Picker])
    ),
    [Netsales]
)

 

If it's useless, please provide a sample .pbix file(Remove sensitive data.).

 

Best regards,
Lionel Chen

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

4 REPLIES 4
v-lionel-msft
Community Support
Community Support

Hi @vishwasrajput66 ,

 

Has your problem been solved?

 

Best regards,
Lionel Chen

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

Fowmy
Super User IV
Super User IV

@vishwasrajput66 

In your Running Net Sales measure, you are using max(VW_RPT_SWGLINTD[Date Picker]). How do you visualize this data? Are you using a table visual with VW_RPT_SWGLINTD[Date Picker] in one column and the Running Net Sales measure?

Please share the screenshot of the report if possible to understand the context in which you are executing the measure.

 

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Website   YouTube    LinkedIn

Hii Fowmy,

 

Yes, I am using a table with the Day of the Date hierarchy. I am attaching a picture for better reference. I have made the above you measure in this table which I have stated above. Both are giving the same results but I am Running Net sales to give cumulative results.

 

Screenshot 2021-05-11 200809.pngCaptur1e.PNG

Hi @vishwasrajput66 ,

 

Please try this.

 

Running Net sales = 
SUMX(
    FILTER(
        ALL(VW_RPT_SWGLINTD),
       [Date Picker] <= MAX([Date Picker])
    ),
    [Netsales]
)

 

If it's useless, please provide a sample .pbix file(Remove sensitive data.).

 

Best regards,
Lionel Chen

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

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors