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
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
Super User

@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! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.

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.