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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
UrAvgWally
Helper I
Helper I

Cumulative Total , no dates

Hi all,

 

I am trying to turn this line chart into a cumulative chart : 

 

UrAvgWally_0-1660667137988.png

 

The data Source looks like this , the X axis is the period Column

UrAvgWally_1-1660667206872.png

 

The Y Axis is based on these values :

UrAvgWally_2-1660667393424.png

Is it possible to cumulative add the Totals so my line chart can show case the cumulative totals rather than value for each period?

 

Also note, I have a slicer which looks at funder and see which department it belongs to. And so the graph changes to data for each department .

Any help would be greatly appreciated :)!

1 ACCEPTED SOLUTION

@UrAvgWally Yeah, there is a stray ) in there:

Measure = 
VAR PNo = MAX(PeriodicTable[PeriodNo])
VAR Periods = 
  SELECTCOLUMNS(
    FILTER(
      ALL(PeriodicTable), 
      [PeriodNo] <= PNo
    ),
    "__PeriodMFMA",
    PeriodicTable[PeriodMFMA]
  )
VAR Table = FILTER(UnpivotCP,[PeriodMFMA] IN Periods)
RETURN
SUMX( Table,[Value])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

13 REPLIES 13
Greg_Deckler
Community Champion
Community Champion

@UrAvgWally Hard to be specific since the data was incomplete without the department and posted as images versus copyable text. But, in general you are going to need to break context in your measure like:

Measure =
  VAR __PNo = MAX('XTable'[PeriodNo])
  VAR __Periods = SELECTCOLUMNS(FILTER(ALL('XTable'),[PeriodNo] <= __PNo,"__PeriodMFMA",[PeriodMFMA])
  VAR __Table = FILTER('YTable',[PeriodMFMA] IN __Periods)
RETURN
  SUMX(__Table,[Value])
  


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler , thanks for getting back to me!

 

Here is more snippets of data which I didnt show earlier :

UrAvgWally_0-1660669255605.png

So the established relationships are  between UnpivotCP[PeriodMFMA] and PeriodTable[PeriodMFMA] and RSKCL[Funder] and UnpivotCP[Funder].

 

With Hopes to use "Period" in Y axis instead of PeriodMFMA and Use RSKCL[Function] as Slicer due to the relationships with Funder.

 

Hope that makes sense, any elaborations , please let me know.

 

I have tried the below measure from what you sent, but I am guessing I made some mistakes typing it..

 

Measure =
VAR PNo = MAX(PeriodicTable[PeriodNo])
VAR Periods = SELECTCOLUMNS(FILTER(ALL(PeriodicTable[PeriodNo] <= PNo,PeriodicTable[PeriodMFMA])
VAR Table = FILTER(UnpivotCP,[PeriodMFMA] IN Periods)
RETURN
SUMX( Table,[Value])
 
Thank you for your help again. 

@UrAvgWally 

VAR Periods = SELECTCOLUMNS(FILTER(ALL(PeriodicTable[PeriodNo]) <= PNo),"__PeriodMFMA",PeriodicTable[PeriodMFMA])



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler   Thanks for getting back to me, unfortunately I am unfortunately still getting a syntax error !

UrAvgWally_1-1660673563485.pngUrAvgWally_2-1660673597126.png

Measure = VAR PNo = MAX(PeriodicTable[PeriodNo])
VAR Periods = SELECTCOLUMNS(FILTER(ALL(PeriodicTable[PeriodNo]) <= PNo),"__PeriodMFMA",PeriodicTable[PeriodMFMA])
VAR Table = FILTER(UnpivotCP,[PeriodMFMA] IN Periods)
RETURN
SUMX( Table,[Value])

 

@UrAvgWally Ah, try this:

VAR Periods = SELECTCOLUMNS(FILTER(ALL(PeriodicTable), [PeriodNo]) <= PNo),"__PeriodMFMA",PeriodicTable[PeriodMFMA])



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Hiya! Still not working 😞 .

UrAvgWally_0-1660686673991.png

Measure = VAR PNo = MAX(PeriodicTable[PeriodNo])
VAR Periods = SELECTCOLUMNS(FILTER(ALL(PeriodicTable), [PeriodNo]) <= PNo),"__PeriodMFMA",PeriodicTable[PeriodMFMA])
VAR Table = FILTER(UnpivotCP,[PeriodMFMA] IN Periods)
RETURN
SUMX( Table,[Value])

@UrAvgWally Yeah, there is a stray ) in there:

Measure = 
VAR PNo = MAX(PeriodicTable[PeriodNo])
VAR Periods = 
  SELECTCOLUMNS(
    FILTER(
      ALL(PeriodicTable), 
      [PeriodNo] <= PNo
    ),
    "__PeriodMFMA",
    PeriodicTable[PeriodMFMA]
  )
VAR Table = FILTER(UnpivotCP,[PeriodMFMA] IN Periods)
RETURN
SUMX( Table,[Value])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

The syntax error has been fixed, it gave an error saying Table is reserved so changed it to Table1, not sure if that is the right thing to do? But to add to that, it is still showing me on the graph, the sum by period rather than cumulative Sum in the graph not sure if it because I changed to Table1?.

 

UrAvgWally_0-1660742734649.png

 

@UrAvgWally Right, one of the reasons I prefix my variables with __ to avoid conflicts like that. Tough to troubleshoot in forums without access to the PBIX or sample data to build the model myself. The theory behind the forumla is that you get the current period as variable Pno so PeriodicTable[PeriodNo] should be used in the X-Axis. You then use that to get all periods equal or less than that period. You can use CONCATENATEX to view the items in that table. Then you filter your unrelated table UnpivotCP for only the rows where the period is in your list of current and previous periods (Periods variable). Perhaps you have a relationship that is messing this up? If so, you could use ALL to get around this like:

VAR Table1 = FILTER(ALL(UnpivotCP),[PeriodMFMA] IN Periods)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Awesome! The code fixed the issue and is now showing cumulative.

 

Although my slicer for different functions not working for that.I ideally want to be able to Slice by function , is there a way to enable that? As per above I use RSKCL[Function] as a slicer, which has a relation to the Funder column.

@UrAvgWally You will want to use ALLEXCEPT instead of ALL in that case. Basically ignore all of the context except for the context you specify.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Alright, thanks . Thank you for being patient with me. Will start reading the book on Dax over the weekend to learn, it is arriving tommorow. 

 

The Allexcept is having syntax error :

 

UrAvgWally_0-1660747606010.png

 

@UrAvgWally ALLEXCEPT takes additional parameters. So something like:

VAR Table1 = FILTER(ALLEXCEPT(UnpivotCP, 'UnpivotCP'[Function]),[PeriodMFMA] IN Periods)

So that code would ignore all context other than context created by a Function column in your UnpivotCP table for example.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.