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

Top Solution Authors