Forum Discussion

BIUser1998's avatar
BIUser1998
Helper I
2 years ago
Solved

Line Chart not plotting measure's entire data

Hello,

 

I have two data tables in PowerBI. One of them is called as calendar which has nothing but the names of the 12 months and the second is shown below.

MonthYearValue
Jan2023386
Feb202382391
Mar20233489
Apr2023348
May202323894
Jun202332498
Jul2023389
Aug202323489
Sept20232348
Oct202332498
Nov202338924
Dec20233289
Jan202424390

I have created a relation between the two months columns with the month column from the calendar table on x-axis and in the filter pane. The filter pane has another filter called Year from the second data table

.

I have created two measures as following

Current Year = VAR SelectedYear = SELECTEDVALUE(‘Values’[Year], BLANK())

RETURN

CALCULATE(SUM(‘Values’[Value], ‘Values’[Year] = SelectedYear)

 

Previous Year = VAR SelectedYear = SELECTEDVALUE(‘Values’[Year], BLANK()) - 1

RETURN

CALCULATE(SUM(‘Values’[Value], ‘Values’[Year] = SelectedYear)

 

I have placed both the measures on the Y-Axis with all the months checked on the filter pane but when the chart is being generated, its only plotting the values for Jan for both the years instead of plotting it for all the months for 2023. Any help regarding the same would be really appreciated. Thank you

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi BIUser1998 ,

     

    I filled in the sample data and made up 24 years of data, and the result should be what you want, please check again.

    And you can see below, there's no year field in Legend.

     

    Best Regards,

    Stephen Tao

     

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

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi BIUser1998 ,

     

    Thank you for reaching us. As far as I understand, you need a chart to show the year you currently selected, and the previous year. Then you should modify the measure to:

     

     

    Previous Year = VAR SelectedYear = SELECTEDVALUE('Values'[Year], BLANK())-1
    
    RETURN
    CALCULATE(SUM('Values'[Value]),FILTER(ALLEXCEPT('Values','Values'[Month]),[Year]=SelectedYear))

     

     

    You can download my attachment for more details.

     

    Best Regards,

    Stephen Tao

     

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

    • BIUser1998's avatar
      BIUser1998
      Helper I

      Hi Anonymous , thank you for your reply.

       

      I need it to look something like this

      Unfortunately, because I'm using data from other tables as well on this particular chart, I cannot just drag the Year field into legend to get a breakdown of year which is why I'm resorting to creating two measures with the data available. Thank you for your help

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi BIUser1998 ,

         

        I filled in the sample data and made up 24 years of data, and the result should be what you want, please check again.

        And you can see below, there's no year field in Legend.

         

        Best Regards,

        Stephen Tao

         

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