cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PietroFarias Regular Visitor
Regular Visitor

Return the percentage of a value in a summarized table

I retrieved a table by DAX STUDIO using the following DAX:

FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( Despesas, filial[razaoSocial], filial[Loja] ),
            "SalarioPago", CALCULATE (
                [despesasPeriodo],
                calendario[Periodo] = "2019/03",
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            )
        ),
        [SalarioPago] < 0
    )

The result was the table below:

exemploDAX.png

I want to create a column called 'percTotal', in which it would be the percent participation of each store over the total value of its company. As in the example below:

exemploDAX2.png

 

And now?

1 ACCEPTED SOLUTION

Accepted Solutions
PietroFarias Regular Visitor
Regular Visitor

Re: Return the percentage of a value in a summarized table

I'm writing a query. So I need to return the additional column in the measure.I got it on another forum. It was as follows:

EVALUATE
ADDCOLUMNS (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( Despesas, filial[razaoSocial], filial[Loja] ),
            "SalarioPago", CALCULATE (
                [despesasPeriodo],
                calendario[Periodo] = "2019/03",
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            )
        ),
        [SalarioPago] < 0
    ),
    "percTotal", FORMAT (
        DIVIDE (
            CALCULATE (
                [despesasPeriodo],
                calendario[Periodo] = "2019/03",
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            ),
            CALCULATE (
                [despesasPeriodo],
                FILTER ( ALL ( calendario ), calendario[Periodo] = "2019/03" ),
                ALLEXCEPT ( Despesas, filial[razaoSocial] ),
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            ),
            BLANK ()
        ),
        "0.00%"
    )
)

View solution in original post

2 REPLIES 2
v-yulgu-msft Super Contributor
Super Contributor

Re: Return the percentage of a value in a summarized table

Hi @PietroFarias ,

 

New a calculated column as below:

percTotal =
Table[SalarioPago]
    / CALCULATE (
        SUM ( Table[SalarioPago] ),
        ALLEXCEPT ( Table, Table[razaoSocial] )
    )


Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
PietroFarias Regular Visitor
Regular Visitor

Re: Return the percentage of a value in a summarized table

I'm writing a query. So I need to return the additional column in the measure.I got it on another forum. It was as follows:

EVALUATE
ADDCOLUMNS (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( Despesas, filial[razaoSocial], filial[Loja] ),
            "SalarioPago", CALCULATE (
                [despesasPeriodo],
                calendario[Periodo] = "2019/03",
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            )
        ),
        [SalarioPago] < 0
    ),
    "percTotal", FORMAT (
        DIVIDE (
            CALCULATE (
                [despesasPeriodo],
                calendario[Periodo] = "2019/03",
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            ),
            CALCULATE (
                [despesasPeriodo],
                FILTER ( ALL ( calendario ), calendario[Periodo] = "2019/03" ),
                ALLEXCEPT ( Despesas, filial[razaoSocial] ),
                Despesas[Despesa] = "FÉRIAS"
                    || Despesas[Despesa] = "SALÁRIOS ZL"
                    || Despesas[Despesa] = "SALÁRIOS JB"
            ),
            BLANK ()
        ),
        "0.00%"
    )
)

View solution in original post

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 46 members 770 guests
Please welcome our newest community members: