Forum Discussion

slam198's avatar
slam198
Frequent Visitor
2 years ago
Solved

Multiple X- Axis Sections

I am looking to re-create an excel chart where the previous 5 year totals, up to the previous 4 month totals, and past 5 reporting week totals are all on the same axis (similar to the below chart). ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi slam198 

    You can refer to the following solution.

    Sample data 

    1.Create a type table

    2.Create a measure.

    Measure2 =
    VAR _year =
        MAXX ( ALLSELECTED ( 'Table' ), YEAR ( [Date] ) )
    VAR _preyear = _year - 4
    VAR _month =
        EOMONTH ( MAXX ( ALLSELECTED ( 'Table'[Date] ), [Date] ), 0 )
    VAR _premonth =
        EOMONTH ( _month, -5 )
    VAR _weekno =
        MAXX ( ALLSELECTED ( 'Table' ), [Date] )
    VAR _preweekno =
        _weekno - 28
            - WEEKDAY ( _weekno - 28, 2 ) + 1
    RETURN
        CALCULATE (
            SUM ( 'Table'[Value] ),
            (
                YEAR ( 'Table'[Date] ) >= _preyear
                    && YEAR ( 'Table'[Date] ) <= _year
                    && FORMAT ( YEAR ( 'Table'[Date] ), "" ) IN VALUES ( 'Table (2)'[Value] )
            )
                || (
                    EOMONTH ( 'Table'[Date], 0 ) >= _premonth
                        && EOMONTH ( 'Table'[Date], 0 ) <= _month
                        && FORMAT ( 'Table'[Date], "mmmm" ) IN VALUES ( 'Table (2)'[Value] )
                )
                || (
                    'Table'[Date] >= _preweekno
                        && 'Table'[Date] <= _weekno
                        && FORMAT ( WEEKNUM ( 'Table'[Date] ), "" ) IN VALUES ( 'Table (2)'[Value] )
                )
        )
    

    Put the type field and the measure to the visual.

    Output

    Best Regards!

    Yolo Zhu

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