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, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Han_Solo
Regular Visitor

Line and Stacked Chart, Line Y Axis is based on a calculated column and is not displaying correctly

Hi Community

I am relativeley new to Power BI so please bear with me. The basics of my model are: Development program with costs and strart and finish dates of when they are incurred. I have also created a custom measure for the cumulative (running total) of costs based on their finish dates. My code is as follows: 

 

Cumulative Total 2 =
    VAR CurrentDate = MAX('Staggered Stage 1 (Lots 3,4,5)'[Date Finish])
    RETURN
    CALCULATE(
        SUM('Staggered Stage 1 (Lots 3,4,5)'[Cost  (inc. GST)]),
        FILTER(
            ALL('Staggered Stage 1 (Lots 3,4,5)'[Date Finish]),
            ('Staggered Stage 1 (Lots 3,4,5)'[Date Finish]) <= CurrentDate
        )
    )
 
I have a Line and Stacked Chart which works perfectly and shows item cost against time as bars and the cumulative total as a line as per the following:
Han_Solo_0-1731205884107.png

 

The Problem: When I introduce another measure, being the item to the "Item" to the x-axis, the Y-line displays incorrectly. It is not longer the running total of the item costs over time. It's basically just reading the Sum of Cost at a particular date, without calclating the running total from previous items in the timeline as per the below: 

Han_Solo_1-1731206319683.png

 

Any ideas would be appreciated and if you need any more info please let me know. 

 

Han. 

1 ACCEPTED SOLUTION

@Han_Solo 

I understand your requirement. I did not ask you to remove the 'Item' column from x-axis, I asked you to remove the filters on 'Item' selection in your cumulative sum measure, like below:

Cumulative Total 2 =
    VAR CurrentDate = MAX('Staggered Stage 1 (Lots 3,4,5)'[Date Finish])
    RETURN
    CALCULATE(
        SUM('Staggered Stage 1 (Lots 3,4,5)'[Cost  (inc. GST)]),
        FILTER(
            ALL('Staggered Stage 1 (Lots 3,4,5)'[Date Finish],'Staggered Stage 1 (Lots 3,4,5)'[Item]),
            ('Staggered Stage 1 (Lots 3,4,5)'[Date Finish]) <= CurrentDate
        )
    )

P.S. I wrote the above measure, assuming your date column and Item column are from same tables, you need to modify the formula further if that is not the case.

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

View solution in original post

4 REPLIES 4
Han_Solo
Regular Visitor

@tharunkumarRTK thanks for the reply. As mentioned, I have another chart which does not include the second x-axis measure which works perfectly. However, I need the second measure so the end user can see when the cost items are incurred. Basically, I need the second x-axis items to show as an x-axis lable only, but the y-line to reference the first x-axis only (being the Date). 

 

Han_Solo_0-1731221451242.png

 

@Han_Solo 

I understand your requirement. I did not ask you to remove the 'Item' column from x-axis, I asked you to remove the filters on 'Item' selection in your cumulative sum measure, like below:

Cumulative Total 2 =
    VAR CurrentDate = MAX('Staggered Stage 1 (Lots 3,4,5)'[Date Finish])
    RETURN
    CALCULATE(
        SUM('Staggered Stage 1 (Lots 3,4,5)'[Cost  (inc. GST)]),
        FILTER(
            ALL('Staggered Stage 1 (Lots 3,4,5)'[Date Finish],'Staggered Stage 1 (Lots 3,4,5)'[Item]),
            ('Staggered Stage 1 (Lots 3,4,5)'[Date Finish]) <= CurrentDate
        )
    )

P.S. I wrote the above measure, assuming your date column and Item column are from same tables, you need to modify the formula further if that is not the case.

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

@tharunkumarRTK Thank you very much, that seems to have solved it! So, for my understanding, is the extra FILTER of 'Staggered Stage 1 (Lots 3,4,5)'[Item]), allowing the Line-y values to read from the Date Finish column? If so, what is the original filter of  'Staggered Stage 1 (Lots 3,4,5)'[Date Finish] doing?

tharunkumarRTK
Super User
Super User

@Han_Solo 

 

I think problem is with your x axis, you added a item into your x axis. It is filtering your value and it is not cumilating the value based on the Date Finish. You should remove the filter on. that column in your measure. 

 

Please share the PBIX file with sample data and expected result for further assistance. 

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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.