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
GarryFarrell
Advocate III
Advocate III

Lifetime Cumulative Total decreasing

Hi all,

 

I have a table (Table 2) that holds static values which will be the starting point for my decreasing cumulative total.

 

Then I have Table 1 which has the data. I made the change measure negative. The tables are joined by an ID.

 

I need help with a DAX formula that uses the staic start point and then uses then cumulative total to decrease the total as shown in the chart below. Thanks in advance everyone.

 

 Tables.PNG

 

Cumulative Total 1.PNG

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @GarryFarrell,

 

Here is the same idea written as a Measure.  Please let me know how that goes.

 

First bring the Starting Point value into Table1 using this calulcated Column

 

Starting Point = RELATED(Table2[Starting Point])

Then you can create the following measure:

 

Cumulative Measure = 
MAX('Table1'[Starting Point])-
+
CALCULATE(
SUM('Table1'[Change]),
FILTER(
ALL(Table1[Date]),
'Table1'[Date]<=MAX('Table1'[Date])
)
)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
Phil_Seamark
Employee
Employee

Hi @GarryFarrell,

 

So long as you have a relationship betwen the two columns, please add this calculated column to your [Table1] and let me know how you get on

 

Cumulative Column = 
var StartingPoint = RELATED('Table2'[Starting Point])
var IDColumn = 'Table1'[ID]
var DateColumn = 'Table1'[Date]
var Result = StartingPoint + CALCULATE(
                                    SUM('Table1'[Change]),
                                    FILTER(
                                        ALL(Table1),
                                        'Table1'[ID] = IDColumn 
                                        && 'Table1'[Date] <= DateColumn
                                        )
                                        )

return Result

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi Phil,

 

Thanks for the solution. It works. However when I use the full data set my PC runs out of memory. Do you think that a measure formula using the same theory would work any differently? I have removed unwanted columns from the queries to try to limit the amount of memory required. I'm running Power BI desktop 64-bit.

 

Regards,

Garry

Hi @GarryFarrell,

 

Here is the same idea written as a Measure.  Please let me know how that goes.

 

First bring the Starting Point value into Table1 using this calulcated Column

 

Starting Point = RELATED(Table2[Starting Point])

Then you can create the following measure:

 

Cumulative Measure = 
MAX('Table1'[Starting Point])-
+
CALCULATE(
SUM('Table1'[Change]),
FILTER(
ALL(Table1[Date]),
'Table1'[Date]<=MAX('Table1'[Date])
)
)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hi,

 

The measure doesn't calculate until it is used. So when designing it is much quicker. However they both cause me to run out of memory with the volume of data that I have and the available RAM.

 

Regards,

Garry

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.