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

Error in Line Stacked Column chart

Hi,

I have some KPIs like market share and basis point change that I want to display in the line and stacked column chart. I want the column chart to only display the last twelve month data from the selected month and year from a slicer. I know the chart is not designed to work this way, but I made some changes and got the columns to display the brand share for only the last twelve months even though my tables have data for the last 3 years. I want the line to display the basis point change but when I put my measure in "Line y-axis" option it display all the past data. 

This is one of the measure which displays the brand market share as columns correctly:

last_12_months_market_share = 
VAR selectedDate  = MAX('Calendar'[Date])
VAR previousDates = DATESINPERIOD(presentation_calendar[Date], selectedDate, -11, MONTH)
VAR Result = 
                CALCULATE(
                            (CALCULATE(SUM(Sales[Dollars])))
                            /
                            (CALCULATE(SUM(Sales[Dollars]),
                                        ALL(Brands[Brand]))),
                            REMOVEFILTERS('Calendar'),
                            KEEPFILTERS(previousDates),
                            USERELATIONSHIP('Calendar'[Date], presentation_calendar[Date])
                            )
RETURN 
    Result

  

This is other measure I wrote but it not working correctly:

test_2 = 
VAR selectedDate = MAX('Calendar'[Date])
VAR previousDates = DATESINPERIOD(presentation_calendar[Date], selectedDate, -11, MONTH)                                  
VAR Result = CALCULATE(
                            (((CALCULATE(SUM(Sales[Dollars])))/
                            (CALCULATE(SUM(Sales[Dollars]),ALL(Brands[Brand]))))
                            -
                            ((CALCULATE(SUM(Sales[Dollars]),
                            SAMEPERIODLASTYEAR(datesbetween('Calendar'[Date],
                            edate(MIN(calendar[Date]),-[selected_end_scale_value]),MAX('Calendar'[Date])))))
                                /
                            (CALCULATE(SUM(Sales[Dollars]),
                            ALL(Brands[Brand]),
                            SAMEPERIODLASTYEAR(datesbetween('Calendar'[Date],
                            edate(MIN(calendar[Date]),-[selected_end_scale_value]),MAX('Calendar'[Date])))))))
                            *1000
                            ,
                            REMOVEFILTERS('Calendar'),
                            KEEPFILTERS(previousDates),
                            USERELATIONSHIP('Calendar'[Date], presentation_calendar[Date])
                            )
RETURN 
    Result

 

This is how it is displayed correcly but when I add the second measure for the line I get the second image:

shou_0-1671472299073.png

shou_1-1671472375077.png

Any suggestions would be helpful. 

Thanks.

 

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

As checked your second screenshot, it seems that you apply another measure in Line field for the visual. It should be the cause of problem... Compared with your first screenshot, there is no data before December, 2021. But it will display the data start from January 2019 when you add the measure in Line field...

 

In order to make troubleshooting and give you a sutiable solution, could you please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community.

How to upload PBI in Community

Best Regards

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.