Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PietroFarias
Resolver II
Resolver II

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

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
Employee
Employee

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.

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%"
    )
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.