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
emma313823
Helper V
Helper V

trend line help

All,

 

Need some help on something that I am unable to figure out. There are 2 primary end goals.

 

1. I have a line visual chart i've created to show 2022 to 2024. If you look at the chart the pink line is 2024. It is plotting data through August as I get new detail, then goes flat from September on. My CEO has asked if there is a way to plot data only through months that have data? i.e. we are still in August, so the chart would display Jan-Aug only. When data begins to arrive in September, then September would show on the chart.

 

emma313823_0-1724689078955.png

 

Not sure if this could be achieved through a measure or if at all.

 

X-Axis is MONTH

Y-Axis is sum of REVENUE

Legend is YEAR

 

To take this a step further...he'd also like to have the oldest year automatically drop off, so it always shows the current year plus the two previous years.

 

On the Data pane...these are the tables and columns being used.

 

Hope a BI guru can help me.

 

emma313823_1-1724689363657.png

 

 

 

 

 

Emma
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @emma313823 ,

 

Thanks Jihwan_Kim  for the quick reply and solution. His solution is good!

I have some ideas to add:

(1) Create two columns on Table[Acctg Revenue].

Year = YEAR([Date])
MonthNum = MONTH([Date])

(2) Create measures.

Sum Revenue = CALCULATE(SUM('Acctg Revenue'[Revenue]),FILTER(ALL('Acctg Revenue'),[Year]=MAX('Calendar_Dates'[Year]) && [MonthNum]=MAX('Calendar_Dates'[MonthNum])))
Max Month = 
var _max_year=MAXX(ALL('Acctg Revenue'),[Year])
var _max_month=MAXX(FILTER(ALL('Acctg Revenue'), [Sum Revenue]<>0 &&[Year]=_max_year),[MonthNum])
RETURN _max_month
Flag = 
var _max_year=MAXX(ALL('Acctg Revenue'),[Year])
var _2_ago=_max_year-2
RETURN IF(MAX('Calendar_Dates'[Year])<=_max_year && MAX('Calendar_Dates'[Year])>=_2_ago && MAX('Calendar_Dates'[MonthNum])<=[Max Month],1,0)

Set [Flag=1] in the Filter Pane.

vtangjiemsft_0-1724826530236.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Hi @emma313823 ,

 

Thanks Jihwan_Kim  for the quick reply and solution. His solution is good!

I have some ideas to add:

(1) Create two columns on Table[Acctg Revenue].

Year = YEAR([Date])
MonthNum = MONTH([Date])

(2) Create measures.

Sum Revenue = CALCULATE(SUM('Acctg Revenue'[Revenue]),FILTER(ALL('Acctg Revenue'),[Year]=MAX('Calendar_Dates'[Year]) && [MonthNum]=MAX('Calendar_Dates'[MonthNum])))
Max Month = 
var _max_year=MAXX(ALL('Acctg Revenue'),[Year])
var _max_month=MAXX(FILTER(ALL('Acctg Revenue'), [Sum Revenue]<>0 &&[Year]=_max_year),[MonthNum])
RETURN _max_month
Flag = 
var _max_year=MAXX(ALL('Acctg Revenue'),[Year])
var _2_ago=_max_year-2
RETURN IF(MAX('Calendar_Dates'[Year])<=_max_year && MAX('Calendar_Dates'[Year])>=_2_ago && MAX('Calendar_Dates'[MonthNum])<=[Max Month],1,0)

Set [Flag=1] in the Filter Pane.

vtangjiemsft_0-1724826530236.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi Guys...

 

Thanks for your patience. I'm still very new to this and am struggling with it quite badly. Would I be able to send the pbix file or at minimum the excel file that this is being used for this visual?

 

Emma

Emma
Anonymous
Not applicable

Hi @emma313823 ,

 

Can you download my attached PBIX file? In my sample the exact same table name as yours.

 

For more details, you can refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Neeko Tang

emma313823
Helper V
Helper V

Would anyone else be able to help solve how to fix this issue based on my last response? HELP PLEASE

Emma
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

In the linechart, 2024 data shows upto August & it only shows the latest three years information.

 

Jihwan_Kim_1-1724692743184.png

 

 

Jihwan_Kim_0-1724692721619.png

 

expected result measure: =
VAR _latestthreeyears =
    WINDOW (
        1,
        ABS,
        3,
        ABS,
        SUMMARIZE ( ALL ( attg_revevue ), 'calendar'[Year] ),
        ORDERBY ( 'calendar'[Year], DESC )
    )
RETURN
    CALCULATE (
        SUM ( attg_revevue[sales] ),
        FILTER ( 'calendar', 'calendar'[Year] IN _latestthreeyears )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi

 

So I tried to make changes to align to my tables and column names, but get an error.

 

emma313823_0-1724704562789.png

 

I didn't change anything except for my table and column names.

 

Emma

Emma

Hi,

can you try writing 'Acctg Revenue' with in the front and   ' in the end ?


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi,

I think that fixed that part, but still not working.

 

YrlyRevUpToCurrMo =
VAR _latestthreeyears =
    WINDOW (
        1,
        ABS,
        3,
        ABS,
        SUMMARIZE ( ALL ( 'Acctg Revenue'[Revenue] ), 'calendar_dates'[Year] ),
        ORDERBY ( 'calendar_dates'[Year], DESC )
    )
RETURN
    CALCULATE (
        SUM ( 'Acctg Revenue'[Revenue]),
        FILTER ( 'calendar_dates', 'calendar_dates'[Year] IN _latestthreeyears )
)
 
shows this:
 
emma313823_2-1724756243036.png

 

My tables and columns being used are:
 
emma313823_1-1724756193159.png

 

 
Emma

Hi,

I think you need to write table name, not the column name for the first argument in the SUMMARIZE DAX function.

Also, there is the difference between what you copy-pasted & screenshot.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.