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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
v-yiruan-msft
Community Support
Community Support

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

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.

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.