Forum Discussion

Gazsim44's avatar
Gazsim44
Helper III
5 years ago
Solved

Add YTD Column in stacked column chart

Hi, I'm currently looking to add an additional column for YTD totals to a chart that currently has Quarters on the x axis. The idea would be that the YTD column would sit after Q4 and would simply up...
  • Icey's avatar
    5 years ago

    Hi Gazsim44 ,

     

    Please try this:

    1. Enter data to create a Columns table like below and then sort "Columns" column by "Order" column.

    Note: no relationship between this new table and your data table.

    Columns Order
    Q1 1
    Q2 2
    Q3 3
    Q4 4
    YTD 5

     

    2. Create measures like so:

    Late Measure =
    VAR Columns_ =
        SELECTEDVALUE ( 'Columns'[Columns] )
    RETURN
        SWITCH (
            Columns_,
            "YTD", CALCULATE ( [YTD], Data[Net Performance] = "MISS" ),
            CALCULATE ( [Late], Data[Quarter] = Columns_ )
        )
    
    On Time Measure =
    VAR Columns_ =
        SELECTEDVALUE ( 'Columns'[Columns] )
    RETURN
        SWITCH (
            Columns_,
            "YTD", CALCULATE ( [YTD], Data[Net Performance] = "OK" ),
            CALCULATE ( [On Time], Data[Quarter] = Columns_ )
        )
    

     

    3. Put 'Columns'[Columns] into "Axis" field and [Late Measure], [On Time Measure] into "Values" field to create a visual.

     

     

    You can this post: Possible Analytics function: dynamic Total column in chart with USA States?

    Not exactly the same, but the logic is the same.

     

     

     

    Best Regards,

    Icey

     

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