Forum Discussion

Sanmaya1's avatar
Sanmaya1
Frequent Visitor
2 years ago
Solved

Need Help in Creating the chart as per explained below

Need to Create a chart which shows LateBacklock and month from next month onwards with fiscal year. Lateback log Quantities are the quantity which are pervious months Quantity and current Month Quant...
  • Anonymous's avatar
    Anonymous
    2 years ago

    lbendlin , thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:

    Hi  Sanmaya1 ,

    I created some data:

     

    Here are the steps you can follow:

    1. Create calculated table.

    Table 2 =
    var _table1=
    DISTINCT('Table'[Year])
    var _table2=
    {"Late Backlog"}
    var _table3=
    CROSSJOIN(
    
        _table1,_table2)
    
    var _table4=
    SUMMARIZE('Table',[Year],[Month])
    var _table5=
    UNION(
        _table4,_table3)
    return
    ADDCOLUMNS(
        _table5,"Date",
        IF(
            [Month]="Late Backlog",BLANK(),
            MINX(FILTER(ALL('Table'),
            [Year]=EARLIER('Table'[Year])&&[Month]=EARLIER('Table'[Month])),[Date])))

    2. Create measure.

    Flag =
    VAR _today =
        TODAY ()
    VAR _startdate =
        EOMONTH ( _today, 0 )
    VAR _enddate =
        EOMONTH ( _today, 3 )
    VAR _nextenddate =
        DATE ( YEAR ( _enddate ) + 1, MONTH ( _enddate ), 1 )
    RETURN
        IF (
            MAX ( 'Table 2'[Month] ) = "Late Backlog"
                || MAX ( 'Table 2'[Date] ) > _startdate
                    && MAX ( 'Table 2'[Date] ) <= _enddate
                || MAX ( 'Table 2'[Date] ) > _nextenddate,
            1,
            0
        )
    
    Value_Measure =
    VAR _today =
        TODAY ()
    VAR _startdate =
        EOMONTH ( _today, 0 )
    VAR _enddate =
        EOMONTH ( _today, 3 )
    RETURN
        IF (
            MAX ( 'Table 2'[Month] ) = "Late Backlog",
            SUMX (
                FILTER (
                    ALL ( 'Table' ),
                    [Year] = MAX ( 'Table 2'[Year] )
                        && 'Table'[Date] <= _enddate
                ),
                [Value]
            ),
            SUMX (
                FILTER (
                    ALL ( 'Table' ),
                    [Year] = MAX ( 'Table 2'[Year] )
                        && [Month] = MAX ( 'Table 2'[Month] )
                ),
                [Value]
            )
        )
    

    3. Place [Flag]in Filters, set is=1, apply filter.

    4. Because Power BI's default sorting is alphabetical, we need to create a sort table if we want to show the desired effect.

    Table 3 =
    SUMMARIZE(
        'Table 2',[Month],
        "date",
        IF(
            [Month]="Late Backlog",MINX(ALL('Table 2'),[Date])-1,
        MINX(FILTER(ALL('Table 2'),[Month]=EARLIER('Table 2'[Month])),[Date])))

    Select [Month] – Column tools – Sort by column – [date]

    5. Joining two tables.

    6. Result:

     

     

    Best Regards,

    Liu Yang

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

    Because