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
Anonymous
Not applicable

How to add a running total line chart on a bar chart

 
9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

Follow these steps:

  1. Create a Calendar Table by going to Modelling > New Table and writing this formula: Calendar = CALENDAR(MIN(Table[Trade Date]),MAX(Table[Trade Date]))
  2. In the Calendar Table, write this calculated column formula to extract Year from the Date: Year = Year(Calendar[Date])
  3. Build a relationship from the Trade Date column to the Date column of the Calendar Table
  4. To your visual, drag Year from the Calendar Table.
  5. Write these measures

Volume traded = SUM(Table[Trade volume])

Volume traded till date = CALCULATE([Volume Traded],DATESBETWEEN(Calendar[Date],MINX(ALL(Calendar]),Calendar[Date]),MAX(Calendar[Date])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Cmcmahan
Resident Rockstar
Resident Rockstar

If date and trade volume are in the same table, this should work.  Why are you using raw_crd_allocations[Trade Date] in your example instead of Table[Trade Date]?

If they're in different tables you may need to change your filter to something like

FILTER(ALL(table), YEAR(table[Trade Date]) <= YEAR(MAX(RELATED(raw_crd_allocations[Trade Date])))

 

Anonymous
Not applicable

upupup

Hi @Anonymous ,

 

I am guessing that 2015 is not the start year for sales you need to set a lower boundary in your filter like

 

Measure = CALCULATE(SUM(table[Trade Volume]),
                                          FILTER(ALL(table),
YEAR(table[Trade Date]) >= YEAR(MIN(raw_crd_allocations[Trade Date])) && YEAR(table[Trade Date]) <= YEAR(MAX(raw_crd_allocations[Trade Date]))))

 

 



I hope this helps,
Richard

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

Proud to be a Super User!


Anonymous
Not applicable

Table should be "table" not "raw.crd.allocations". Sorry for mixing them... It is still the original number. Not sure why....

Anonymous
Not applicable

For example for 2015, the cumulated value should be 0.39T not 1.3T... It is confusing

Real quick, could you create a new calculated column with this portion of your code?

 

COLUMN = VALUES(table[Trade Volume]), FILTER(ALL(table), YEAR(table[Trade Date]) <= YEAR(MAX(table[TradeDate])))

I'm curious to see what values it IS using in the SUM, if it isn't using the right values.

 

Is this graph being filtered in another way?  Say by some category?  If so, the ALL(table) might be removing those filters and giving a full total instead of just the subset this graph is for.  You can use ALL(table[column]) to just remove those filters:

 

FILTER(ALL(table[Trade Date]), YEAR(table[Trade Date]) <= YEAR(MAX(table[Trade Date]))
Anonymous
Not applicable

It is much larger than the cumulated value...

Anonymous
Not applicable

Raw data in table in database is something like:

 

Trade Date     Trade Volume

1/6/2015         435222.4512

1/4/2015        232224.2243

3/6/2016       132345.3333

........                     ......

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.