Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Return value from column

I´m making a report sales, and I have a table like this...   IDCtmr   State   Company   Month   SaleType   Volume 001   NY   Microsoft   201801   Regular   50,000 001   NY   Mi...
  • v-lid-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    We think the matrix visual should meet your requirement.

     

     

    In case you need a calculated table, you can use the following formula ( Consider of the length, I just put part of them)

     

    NewTable =
    VAR montht =
        ADDCOLUMNS (
            DISTINCT ( 'Table'[Month] ),
            "index", RANKX ( DISTINCT ( 'Table'[Month] ), [Month],, ASC )
        )
    VAR resultt =
        ADDCOLUMNS (
            DISTINCT (
                SELECTCOLUMNS (
                    'Table',
                    "IDCtmr", [IDCtmr],
                    "State", [State],
                    "Company", [Company]
                )
            ),
            "Mont_M1", MAXX ( FILTER ( montht, [index] = 1 ), [Month] ),
            "SaleType _M1", MAXX (
                FILTER (
                    'Table',
                    'Table'[Month]
                        = MAXX ( FILTER ( montht, [index] = 1 ), [Month] )
                ),
                [SaleType]
            ),
            "Volume_M1", SUMX (
                FILTER (
                    'Table',
                    'Table'[Month]
                        = MAXX ( FILTER ( montht, [index] = 1 ), [Month] )
                ),
                [Volume]
            ),
            "Mont_M2", MAXX ( FILTER ( montht, [index] = 2 ), [Month] ),
            "SaleType _M2", MAXX (
                FILTER (
                    'Table',
                    'Table'[Month]
                        = MAXX ( FILTER ( montht, [index] = 2 ), [Month] )
                ),
                [SaleType]
            ),
            "Volume_M2", SUMX (
                FILTER (
                    'Table',
                    'Table'[Month]
                        = MAXX ( FILTER ( montht, [index] = 2 ), [Month] )
                ),
                [Volume]
            )
    ADD MORE MONTH HERE ) RETURN resultt

     

     

    But it need to add cord for every month, so does the measure or calculated column.

     

     

     

    BTW, pbix as attached.

     

    Best regards,

    Community Support Team _ Dong Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.