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
Anonymous
Not applicable

Last value instead of average in total

I have a matrix in powerbi with 3 measures that are calculated as a weighted average. The total column is showing the average of the columns displayed but I want it to display the last value instead. Any idea how can I do that?

 

The formula I am using to calculate the KPI is:

SUMX(
table1,
table1[Average]*table1[weight])/
SUM(table1[weight])

Something like this

 q1q2q3q4Total nowTotal desired
KPI 158910810
KPI 261934.753
KPI 364624.52

 

Thank you!

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Let’s assume that your metric is called value

Value = SUMX(
table1,
table1[Average]*table1[weight])/
SUM(table1[weight])

 

You create the following measure using ISINSCOPE.

Final Value = IF(ISINSCOPE('table1'[q]),[Value],CALCULATE([Value],FILTER('table1',[q]="q4")))

14.png

 

Attached is the sample I created, there may be some discrepancies, you can refer to it.

 

Best Regards,

Stephen Tao

 

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

 

View solution in original post

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Let’s assume that your metric is called value

Value = SUMX(
table1,
table1[Average]*table1[weight])/
SUM(table1[weight])

 

You create the following measure using ISINSCOPE.

Final Value = IF(ISINSCOPE('table1'[q]),[Value],CALCULATE([Value],FILTER('table1',[q]="q4")))

14.png

 

Attached is the sample I created, there may be some discrepancies, you can refer to it.

 

Best Regards,

Stephen Tao

 

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

 

Anonymous
Not applicable

Hello @v-stephen-msft 

Thank you so much, it worked exactly as I wanted it.

thedatahiker
Employee
Employee

@Anonymous You can try something like this.

In this solution, you will need a date table. 

 

 

Var TableWeight =  SUM ( Table1[Weight] )
RETURN
CALCULATE (
DIVIDE ( Table1[Average] * Table1[Weight], TableWeight ),
LASTDATE( 'Date'[Date] )
)

 

 

 

 

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.