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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Cumulative Total Line Graph Showing Legends by Year & Daily Granularity but X Axis Labelled by Month

HI there,

Following previous help, I have a line graph as below which i have created to look like this:
Axis:
Date:
   Month

   Day

 

Legend:

Date:

   Year

 

Values:

cumulative

 

DAX Measure:

cumulative = CALCULATE(SUM(DATA[PnL]),FILTER(ALL(DATA),DATA[Date]<=MAX(DATA[Date])),VALUES(DATA[Year]))

 

 

julesdude_0-1642679375798.png

 

My DATA table is the only table in the model. I actually don't have a calendar table but might add it if I really must. For the moment I've kept things simple and created additional Custom Columns in Power Query that reference the Date column. The DATA table looks a little something like this:

 

DatePnLYearMonth NumberMonth NameDayOfYearIndex
01/01/2022

10

20221January11
02/02/2022-520222February22
20/06/20216420216June

171

3
27/06/20218320216June1784
28/06/20212120216June1795
29/06/2021-1020216June1806
02/04/2020-4320204April927
03/04/20204820204April938
04/04/20209620204April949
05/04/20202320204April9510

 

My requirement is that whilst the graph above is ok, I have daily granular detail in my table, pretty much for each day going back a number of years, and current graph resolution is showing monthly granularity. I would like daily granularity. If i drill down a level using the drill-down icon, it groups the PnL into day groups from 1 -31 to correspond with each day of each month, which doesn't work.

I know I could just use the DayOfYear attribute from the table as an index reference, but that would then give me labels on my x axis of 1 - 365. I would kind of still like the labels to remain showing monthly categories so the viewer can see monthly index points.

How do I achieve this?

Finally, you'll notice that the current year's PnL flatlines across from last date available to the end of the axis. I would want this to be blank for future dates of the year. I think this is achieved by a simple IF statement in the DAX which detects current date, but how do I express this?

 

7 REPLIES 7
staso
Regular Visitor

I have the exact same issue, were you able to resolve? I found adding the date to a tooltip is a clunky alternative however with the leap years, dates after 28th of Feb are offset by 1 day.

diego_ba01
New Member

were you able to figure it out? i need help with the same thing. please let me know. thank you so much!

Anonymous
Not applicable

Hmmm, still trying for a solution on this one but no luck. I would like the x axis to display month labels rather than day of the year labels, so granularity can be by day, and secondly for the current year I need the line to stop at the current date rather than continue to the end of the graph.
Can anyone help?

Anonymous
Not applicable

Hi @Anonymous 

Thanks for getting back to me. This looks good, however what I need is for the lines to be stacked together on a timeline spanning a year rather than run across a continual timeline.

Can it be tweaked?

Anonymous
Not applicable

Can anyone provide help? I can add a calendar table if needs be.

Anonymous
Not applicable

Hi @Anonymous ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a calculated column as below to get YearMonth

YearMonth = YEAR ( 'DATA'[Date] ) & FORMAT ( 'DATA'[Date], "MMMM" )

2. Create a line chart with below settings

yingyinr_0-1643100708186.png

Best Regards

Anonymous
Not applicable

Thanks for getting back to me @Anonymous . Sorry I think I replied in the wrong place. This looks good, but not quite there - the lines need to be grouped not spread like that, like in my first graph. I would like the x axis to display month labels rather than day of the year labels, so granularity can be by day, and secondly for the current year I need the line to stop at the current date rather than continue to the end of the graph.

Can it be tweaked?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.