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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
vishwasrajput66
New Member

Cumulative sum with calculated measure as field in power BI

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
HashamNiaz
Solution Sage
Solution Sage

Hi !

 

You can get the desired out using following DAX measure;

 

Running Net Sales = 
CALCULATE(
	[Netsales],
	FILTER(
		ALLSELECTED('Calendar'[Date]),
		ISONORAFTER('Calendar'[Date], MAX('Calendar'[Date]), DESC)
	)
)

 

You can replace the 'Calendar' dimension name with your date table in the DAX formula.

 

Regards,

Hasham

View solution in original post

4 REPLIES 4
HashamNiaz
Solution Sage
Solution Sage

Hi !

 

You can get the desired out using following DAX measure;

 

Running Net Sales = 
CALCULATE(
	[Netsales],
	FILTER(
		ALLSELECTED('Calendar'[Date]),
		ISONORAFTER('Calendar'[Date], MAX('Calendar'[Date]), DESC)
	)
)

 

You can replace the 'Calendar' dimension name with your date table in the DAX formula.

 

Regards,

Hasham

Hii Hasham,

 

I tried your solution. It didn't work. I created this:-

Running Net Sales =
CALCULATE(
    [Net sales],
    FILTER(
        ALLSELECTED(VW_RPT_SWGLINTD[Date Picker]),
        ISONORAFTER(VW_RPT_SWGLINTD[Date Picker], MAX(VW_RPT_SWGLINTD[Date Picker]), DESC)
    )
I have uploaded the result below, NetSales and running net sales are still same.

Regards,
Vishwas
)Screenshot 2021-05-11 200809.png

Hi !

Try to use the VW_RPT_SWGLINTD[Date Picker] column in your matrix.

 

Regards,

Hii,

I was using VW_RPT_SWGLINTD[Date Picker] as a hierarchy. When I used it as a single dimension. It worked. thank you

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.