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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
CristianoYnos
Frequent Visitor

Criar soma acumulada

Pessoal, preciso criar uma medida que faça a soma acumulada dos valores. Tenho uma matriz com 4 colunas, conforme print abaixo. Essas colunas vem de duas tabelas dimensão (dDocumentos e dRegistro_PC_LCDPR), e o valor vem da tabela fato. Eu já utilizei o novo recurso de calculo visual, porém ao publicar na web via link publico ele não funciona. Com isso, preciso criar uma medida.

CristianoYnos_0-1714484615727.png

Fiz a tentativa utilizando a seguinte medida para primeiro retornar o ALL da coluna nome. 
   Vlr. Acum =
   VAR Nome = SELECTEDVALUE(dDocumentos[Nome])
   RETURN
   CALCULATE(SUM([Valor]),  FILTER(ALL(dDocumentos[Nome]),dDocumentos[Nome] <= Nome))

 

Após isso, criei nova medida que usa na calculate a medida anterior "Vlr. Acum"
Vlr. Acum 2 =
VAR Classific = SELECTEDVALUE(dRegistro_PC_LCDPR[Classificação])
RETURN
CALCULATE([Vlr. Acum],FILTER(ALL(dRegistro_PC_LCDPR),dRegistro_PC_LCDPR[Classificação] <= Classific)).

Mas ao colocar a medida "vlr Acum 2 na matriz não funciona, e mesmo se eu crio uma medida "3", colocando agora o ALL para a coluna Descrição e depois uma medida "4" com a coluna tipo de lançamento, não da certo. 
Alguem pode me ajudar por favor?

 

2 REPLIES 2
v-rongtiep-msft
Community Support
Community Support

Hi @CristianoYnos ,

To create a cumulative sum in Power BI, you can use the DAX CALCULATE function along with SUM and FILTER, and apply the ALLSELECTED function to keep the context of the filters applied in the visualization.The ALLSELECTED function may be better suited for this scenario because it keeps the applied filters in the dimension, unlike ALL, which will remove all filters.

 

Create a measure.

Soma Acumulada = 
CALCULATE(
    SUM(fato[Valor]),
    FILTER(
        ALLSELECTED(dDocumentos),
        dDocumentos[Nome] <= MAX(dDocumentos[Nome])
    )
)

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

 

Prezado, obrigado pela contribuição. Fiz conforme mencionou, porém a soma nao acumulou pois tenho mais 3 colunas que vem de outra tabela dimensão. Isto funcionaria se eu tivesse na minha matriz somente a coluna [Nome].

CristianoYnos_0-1714650176844.png

 


Tentei uma segunda formula, usando a "soma acumulada" acima na expressao da calculate, mas aí da erro na no visual da matriz, dizendo que excedeu os limites. Se tiver outra alternativa agradeço muito.

CristianoYnos_1-1714650248480.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.