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
renmello
Helper I
Helper I

Accumulating values from the line context

Hello, everyone!! I would like to share an issue i am facing with no solution so far. It would be glad with any help 🙂

I have a table that shows the accumulate and the percentage accumulated over months. I also have a table that gets the values by Gerência. As the image below shows:

Tabela Exemplo 2.PNG


When i click any line from the Gerência column the top table keeps the total value of [Custo LB Fixa] to get the percentages of measures 3 and 4. As the image shows:

 

Tabela Exemplo 1.PNG

I would like to know if i could in the same measure (measure 4) change the filter context to row context.

 

Being specific: I would like to filter the accumulate over the months also by gerencia. So the total would change when i filter from the Sum of all [Custo LB] to the [Custo LB] of the Gerência.  Without changing the total from [Custo LB] when it is not filtered.

 

I would like to do this because i have a chart that i dont want to mess up and i would like the chart to filter by the total of gerencia and not the whole total as it is doing right now.


I am using four measures, listed below with comments:

//Measure 1: accumulates [Custo realizado] over months

realizado Acumulado =
Calculate([Custo realizado],
filter(
all('CalendarioDAX'),
'CalendarioDAX'[Data]<=max('CalendarioDAX'[Data])
)
)

//Measure 2: divides [Custo realizado] over [Custo LB] to get the percentage by gerência from its [Custo LB]

% Executada LB Gerência = Divide([Custo realizado],[Custo LB],0)

// Measure 3: that divides [Custo realizado] over [Custo LB Fixa] to get the percentage by gerência from the total [Custo LB]. [Custo LB Fixa] is the [Custo LB] with all

% Executada LB IU = Divide([Custo realizado],[Custo LB Fixa],0)


// Measure 4: accumulates the percentages over the months

% LB Acumulada IU =
Calculate([% Executada LB IU],
filter(all(CalendarioDAX),
CalendarioDAX[Data]<=max(CalendarioDAX[Data])
)
)


//CalendarioDax is the name of the calendar table.
// [Custo realizado], [Custo LB] and [Custo LB Fixa] are simple sum measures.

Well, i hope i was clear in my explanation. Sorry about any english mistakes.  


1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@renmello  The Simple SUM with ALL for [Custo LB Fixa] is what you need to fix. This is the only measure you didn't provide DAX for, but you need to replace ALL() with ALLSELECTED(Table[Gerencia]) if I am understanding correctly (or experiment with changing this measure).

 

// Measure 3: that divides [Custo realizado] over [Custo LB Fixa] to get the percentage by gerência from the total [Custo LB]. [Custo LB Fixa] is the [Custo LB] with all

% Executada LB IU = Divide([Custo realizado],[Custo LB Fixa],0)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
renmello
Helper I
Helper I

Hey, thanks for the solution. Sorry it took this long to answer this topic, i was able to test it just yesterday. Again, thanks for your help and attention!

AllisonKennedy
Super User
Super User

@renmello  The Simple SUM with ALL for [Custo LB Fixa] is what you need to fix. This is the only measure you didn't provide DAX for, but you need to replace ALL() with ALLSELECTED(Table[Gerencia]) if I am understanding correctly (or experiment with changing this measure).

 

// Measure 3: that divides [Custo realizado] over [Custo LB Fixa] to get the percentage by gerência from the total [Custo LB]. [Custo LB Fixa] is the [Custo LB] with all

% Executada LB IU = Divide([Custo realizado],[Custo LB Fixa],0)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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