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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Car_95
Regular Visitor

Como somar a linha atual com a anterior?

Olá, 
Tudo bem com todos?
Eu consigo fazer uma conta somando e multiplicando o valor resultante da linha atual com a linha anterior como se fosse um loop?
Estou tentando um CALCULATE mas não está me trazendo o valor que necessito!
Agradeço desde de já a atenção.
Captura de Tela 2022-10-04 às 11.04.20.png

1 ACCEPTED SOLUTION

@Car_95 

You need to add index column using power query. The following formula will give the the cumulative total up to the current row. 

=
VAR CurrentIndex = im[Index]
RETURN
    SUMX ( FILTER ( im, im[Index] <= CurrentIndex ), im[valor] )

View solution in original post

8 REPLIES 8
Car_95
Regular Visitor

Oi @tamerj1 
Não a coluna de data é duplicada, muita das capturas foram feitas na mesma data!
Não sei se vou conseguir deixar bem claro a conta pra você pois é uma conta em C++ que pediram pra eu passar pra DAX 😅
Mas seria essa que andei tentando o retorno:
VAR 
data = (im[datacaptura])
RETURN
CALCULATE ( SUM (im[valor]) FILTER (im[datacaptura] <= data))
Que devo está errando provavelmente no filter e na coluna de data por estarem repetidas as datas!!
O contexto da fórmula em C++ é comparar o valor anterior com da linha atual pra ver se o valor está dentro da porcentagem aceitável!
Que é essa :
imInferior + imatual * 0.50
Eu precisaria da coluna calculada!!!
Muito obrigada pela ajuda.

Captura de Tela 2022-10-04 às 15.11.55.png

@Car_95 

You need to add index column using power query. The following formula will give the the cumulative total up to the current row. 

=
VAR CurrentIndex = im[Index]
RETURN
    SUMX ( FILTER ( im, im[Index] <= CurrentIndex ), im[valor] )

Tenho uma base em que alguns motivos de contato aparecem a mesma quantidade de vezes. A fórmula 

Pareto =

         var TotalMotivos = CALCULATE([KPI_QTDE MOTIVOS], ALLSELECTED(Ft_KPI))
       
        var TotalMotivosAtual = [KPI_QTDE MOTIVOS]
     
        var tbResumo = SUMMARIZE(
                ALLSELECTED(Ft_KPI),
                Ft_KPI[Motivo de contato],
                "Total", [KPI_QTDE MOTIVOS]
        )
       
        var TotalAcumulado = SUMX( filter(tbResumo,  [Total] >= TotalMotivosAtual), [Total])

        RETURN
       
       TotalAcumulado

gera o seguinte resultado 
TulioAraujo789_0-1675449517068.png



Quando os motivos possuem o mesmo contato a medida "Pareto" não se comporta somando cada linha, podem me ajudar a solucionar essa questão?



Hi @TulioAraujo789 
Pretty sure there is a simpler way to handle this situation, however, this method seems to work just fine

1.png

KPI_RANKIN Pareto = 
VAR CurrentValue = [KPI_QTDE MOTIVOS]
VAR CurrentContato = SELECTEDVALUE ( Ft_KPI[Motivo de contato] )
VAR AllContato = ALLSELECTED ( Ft_KPI[Motivo de contato] )
VAR CurrentRank1 = RANKX ( AllContato, CALCULATE ( SELECTEDVALUE ( Ft_KPI[Motivo de contato] ) ) )
VAR CurrentRank2 = 10000 * CurrentValue + CurrentRank1
RETURN
    SUMX (
        FILTER (
            ADDCOLUMNS (
                ADDCOLUMNS (
                    AllContato,
                    "@Value", [KPI_QTDE MOTIVOS],
                    "@Rank1", RANKX ( AllContato, Ft_KPI[Motivo de contato] )
                ),
                "@Rank2", 10000 * [@Value] + [@Rank1] 
            ),
            [@Rank2] >=  CurrentRank2
        ),
        [@Value]
    )

Oi @tamerj1 
Muito obrigada pela ajuda !!!!
Deu super certo !!!!
Agradeço a sua atenção !!
😄

Car_95
Regular Visitor

Olá @tamerj1 !!
E tenho uma coluna de data!
A que tenho é data de captura desses valores mas não sei se o filter que estou usando no argumento da sentença está errado pois está me trazendo todos os valores iguais!
A coluna de índice eu não tentei!
Coloco uma coluna de índice e permaneço com CALCULATE mesmo? 
Muito obrigada pela ajuda.

Hi @Car_95 

I will propose a formula for you. But I still need some clarifications

1. is the date column unique? meaning no duplicate dates?
2. what kind of calculation would like to perform? Can place one example?

3. Do you want to create a measure or a calculated column?

 

thank you

tamerj1
Super User
Super User

Hi @Car_95 

do you have a unique date or index column? If not can you add an index column? If so then yes it is possible. Please provide more details about the required calculation 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.