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
ThiagoProfitt
Frequent Visitor

Running Totals AND SUM in the same Matrix

I'm currently developing a cash flow matrix and failed while trying to merge two measures in one (running totals and sum):
My idea was to add boolean indicators (Calculado Column) as such:

ThiagoProfitt_1-1618920738275.png

So that my measure could do the following:

Subtotal = 

var Calculado = SELECTEDVALUE('Categorias'[Calculado])

var Runningtotal= [Running total]

Return

SWITCH(

True(),

Calculado = 0, [Total],

Calculado = 1, Runningtotal,

BLANK()

)

The referenced measures are:

Running total =
CALCULATE(

    [Total],

    FILTER(

        ALLSELECTED('Calendário'[Data]),

        ISONORAFTER('Calendário'[Data], MAX('Calendário'[Data]), DESC)

    )

)

The [Total] measure:

 

[Total] = SUM(Movimentacoes[nValorTitulo])

When [Running Total] is in a matrix by itself it works absolutely fine, also does [Total], however if I mix both using the [Subtotal] measure, the [Running Total] results in 0 and the sum measure [Total] works just fine.

ThiagoProfitt_2-1618921325334.png
 
Is there any way to mix both of those in the same matrix? or maybe a way to scroll through two matrix visuals at the same time?
1 ACCEPTED SOLUTION
ThiagoProfitt
Frequent Visitor

Managed to fix it:
Had to add an Index column and edit the measure:

Subtotal = 

var Calculado= SELECTEDVALUE(Categorias[Calculado])

var ordemContexto = Max('Categorias'[Índice])

var ValorSubtotalresumo =

CALCULATE([Running Total],Filter(ALLNOBLANKROW('Categorias'), 'Categorias'[Índice] >= ordemContexto))

Return

SWITCH(

True(),

Calculado = 0, [Total],

Calculado = 1, ValorSubtotalresumo,

BLANK()

)

View solution in original post

1 REPLY 1
ThiagoProfitt
Frequent Visitor

Managed to fix it:
Had to add an Index column and edit the measure:

Subtotal = 

var Calculado= SELECTEDVALUE(Categorias[Calculado])

var ordemContexto = Max('Categorias'[Índice])

var ValorSubtotalresumo =

CALCULATE([Running Total],Filter(ALLNOBLANKROW('Categorias'), 'Categorias'[Índice] >= ordemContexto))

Return

SWITCH(

True(),

Calculado = 0, [Total],

Calculado = 1, ValorSubtotalresumo,

BLANK()

)

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.