Forum Discussion

aashudream's avatar
aashudream
Regular Visitor
4 years ago
Solved

Months and Quarters side by side

I would like to see Months and Quarters side by side and not have to drill down in the visual.. any suggestion?   Month and values changed as per selection for last 12 month.    
  • v-yanjiang-msft's avatar
    4 years ago

    Hi aashudream ,

    According to your description, if the data you showed above is a matrix, Indicates that in the date column, all dates are in the same column as the quarters, this requires create a new table.

    Table 2 = UNION(VALUES('Table'[Date]),{"Q1","Q2","Q3","Q4"})

    Then create three measures.

    GSV =
    VAR _A =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Global category] = MAX ( 'Table'[Global category] )
                    && FORMAT ( 'Table'[Date], "M/D/YYYY" ) = MAX ( 'Table 2'[Date] )
            ),
            'Table'[GSV]
        )
    RETURN
        SWITCH (
            MAX ( 'Table 2'[Date] ),
            "Q1",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[GSV]
                ),
            "Q2",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q2"
                    ),
                    'Table'[GSV]
                ),
            "Q3",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q3"
                    ),
                    'Table'[GSV]
                ),
            "Q4",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[GSV]
                ),
            _A
        )
    
    Net Sales =
    VAR _A =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Global category] = MAX ( 'Table'[Global category] )
                    && FORMAT ( 'Table'[Date], "M/D/YYYY" ) = MAX ( 'Table 2'[Date] )
            ),
            'Table'[Net Sales]
        )
    RETURN
        SWITCH (
            MAX ( 'Table 2'[Date] ),
            "Q1",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[Net Sales]
                ),
            "Q2",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q2"
                    ),
                    'Table'[Net Sales]
                ),
            "Q3",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q3"
                    ),
                    'Table'[Net Sales]
                ),
            "Q4",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[Net Sales]
                ),
            _A
        )
    
    Gross Profit =
    VAR _A =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Global category] = MAX ( 'Table'[Global category] )
                    && FORMAT ( 'Table'[Date], "M/D/YYYY" ) = MAX ( 'Table 2'[Date] )
            ),
            'Table'[Gross Profit]
        )
    RETURN
        SWITCH (
            MAX ( 'Table 2'[Date] ),
            "Q1",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[Gross Profit]
                ),
            "Q2",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q2"
                    ),
                    'Table'[Gross Profit]
                ),
            "Q3",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q3"
                    ),
                    'Table'[Gross Profit]
                ),
            "Q4",
                SUMX (
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Global category] = MAX ( 'Table'[Global category] )
                            && 'Table'[Quarter] = "Q1"
                    ),
                    'Table'[Gross Profit]
                ),
            _A
        )
    

    Get the correct result.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

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