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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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?

 

6 REPLIES 6
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 @v-yiruan-msft 

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.

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks for getting back to me @v-yiruan-msft . 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

October NL Carousel

Fabric Community Update - October 2024

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