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
sprasad
Helper II
Helper II

Incremental summing of values

I have this table with Date, State and CountState. I want to know how to calculate the cummulative values in the "Incremeatal Values Date wise" based on the "State" so that I can prepare the graph as shown below:

 

DateStateCountStateIncremental Values Date wise
18-Feb-19Active22
19-Feb-19Active13
07-Feb-19Active25
14-Feb-19Active16
10-Jan-19Active17
31-Jan-19Active12
04-Jan-18Closed11
03-Nov-17Closed12
23-Oct-17Closed13
12-Dec-17Closed14
07-Nov-17Closed15
26-Feb-18Closed16
17-Nov-17Closed511
02-Nov-17Closed112
31-Oct-17Closed315
19-Oct-17Closed217
04-Dec-17Closed118
05-Dec-17Closed119

 

Cumulative.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PattemManohar 

I checked your dataset. I think you were wrong at the line 10th. because the state is active and Project is Project B it means we run across it for first time it should be 1 for Running total by state & Project column.

Please create a new column like that

column = CALCULATE(SUM(Table1[CountState]);FILTER(Table1;Table1[State]=EARLIER(Table1[State])&&Table1[Project]=EARLIER(Table1[Project])&&Table1[MergedDate - Copy]<=EARLIER(Table1[MergedDate - Copy])))

 

View solution in original post

7 REPLIES 7
PattemManohar
Community Champion
Community Champion

@sprasad  The expected column name was contradicting with the requirement statement. That's why, I'm provding two options.

 

1. If you want the Running Total based on State by Date Wise. Add a New Column as below

 

RunningTotalByStateDate = 
VAR _CurrentCount = Test211RunningTotal[CountState]
VAR _PreviousCount = CALCULATE(SUM(Test211RunningTotal[CountState]),FILTER(ALL(Test211RunningTotal),Test211RunningTotal[Date]<=EARLIER(Test211RunningTotal[Date]) && Test211RunningTotal[State] = EARLIER(Test211RunningTotal[State])))
RETURN _PreviousCount 

2. If you want the Running Total based on State itself without any order (based on the default order of the data present). Then add an Index column in Power Query Editor and add a new column in Modeling Tab (DAX) as below

 

RunningTotalByState = 
VAR _CurrentCount = Test211RunningTotal[CountState]
VAR _PreviousCount = CALCULATE(SUM(Test211RunningTotal[CountState]),FILTER(ALL(Test211RunningTotal),Test211RunningTotal[Index]<=EARLIER(Test211RunningTotal[Index]) && Test211RunningTotal[State] = EARLIER(Test211RunningTotal[State])))
RETURN _PreviousCount 

image.png

 





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

Proud to be a PBI Community Champion




I think I sent the wrong table. 

Now if you can see we have the State Column having the value as New,  Closed and Active. Project has value as project A, Project M, project B. So I want the "Running Total by State & Project"

MergedDate - CopyStateProjectCountStateRunning Total By State & Project
28-Sep-17NewProject A11
23-Oct-17ClosedProject M11
26-Jan-18ClosedProject M12
29-Jan-18ClosedProject A22
30-Jan-18ClosedProject A46
30-Jan-18NewProject B11
31-Jan-18ClosedProject A612
31-Jan-18ClosedProject M13
06-Feb-18ClosedProject A719
07-Feb-18ActiveProject B12
18-May-18ClosedProject R1 

 

Is it possible, pls help me to do this.

Anonymous
Not applicable

Hi @PattemManohar 

I checked your dataset. I think you were wrong at the line 10th. because the state is active and Project is Project B it means we run across it for first time it should be 1 for Running total by state & Project column.

Please create a new column like that

column = CALCULATE(SUM(Table1[CountState]);FILTER(Table1;Table1[State]=EARLIER(Table1[State])&&Table1[Project]=EARLIER(Table1[Project])&&Table1[MergedDate - Copy]<=EARLIER(Table1[MergedDate - Copy])))

 

Can't we do this calculation in the query table by creating a custom column itself? I want to use other columns in the tquery table to display the details. So if everything is available in the single table then it is easy for me

@Anonymous  It was based on the sample test data that was provided initially, but now you have different structure of data. So the same solution will not work for that. Anyway, I hope now you have solved that.





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

Proud to be a PBI Community Champion




I think PattemManohar  solution was based on the previous table.

 

Thanks

Anonymous
Not applicable

Hi @sprasad your date column is irregular. It should be have a sort logic Ascending or descending. I think we were unable to do that in this sort.

I suppose it would be descending sort if it's okey for you.

Column = CALCULATE(SUM(Table1[CountState]);FILTER(Table1;Table1[State]=EARLIER(Table1[State])&&Table1[Date]>=EARLIER(Table1[Date])))

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.