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

calculate weighted index

I am trying to make a Measure where I want to calculate weighted index by the following formula:

 

Weighted CAP index = [CAP Index]*[Actuals]/"the Total of [Actuals]"

 

but I don't know how to refer to "the Total of [Actuals]"?

 

If you don't know what I mean I will make a screendump...

1 ACCEPTED SOLUTION

Hi @flunte70,

 

Create a new measure and use it on your column:

 

Height Total =
IF (
    HASONEVALUE ( Data[Nummer] ),
    [Height],
    SUMX ( ALL ( Data[Nummer], Data[SC specifikation] ), [Height] )
)

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

16 REPLIES 16
AndrejZitnay
Post Patron
Post Patron

Hello @flunte70

 

I would try

 

 

Weighted CAP index = SUMX(Sheet1,Sheett1[CAP index}*Sheet1[Actuals])/SUM(Sheet1[Actuals])

 

This is how weighting average works for me.

Imagine that your data are on Sheet1.

I am assuming that CAP index is percantage and you have to do weighing by Actuals.

 

Kind regards.

Andrej

MFelix
Super User
Super User

Hi @flunte70,

 

No sure if this is what you need but believe that you need to have a formula like this for the total of actuals:

 

Total actuals = CALCULATE ([Actuals], Table[Date] <= MAX (Table[Date])

But witouth any further insights not sure how this relates to your data.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix,

 

I get the error "A Function ´MAX` has been used in a True/False expression..." so I don't know what I do wrong?

 

Sum Actual Max = CALCULATE([Actuals]; Data[Service Component] <= Max (Data[service Component]))

 

I have also tried to use:

 

Sum Actuals = CALCULATE([Actuals];ALL(Data[SC specifikation])) but that only gives me the same values as [Actuals]...

 

Below I have made a screendump of my report (drill down) and my tables

 

18-12-2017 13-51-03.jpg18-12-2017 13-51-41.jpg

Change your measure to:

 

Sum Actual Max =
VAR MAX_Component =
    MAX ( Data[service Component] )
RETURN
    CALCULATE ( [Actuals]; Data[Service Component] <= MAX_Component )

Should do the trick.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix - thanks for the suggestion - unfortunately it is not solving the issue as the amount is still the same and not the total...

 

19-12-2017 15-02-23.jpg

Can you say what numbers you want to divide?

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Off course my friend 🙂

 

I want to end up with a measure based on the following formula:

 

"KAP index" x "Actuals" : "Total Actuals"

 

So I thought that I should first make a measure that gives the "Total Actuals" in every shown row (in above screendump it is the Total amount in the 3rd column = 114.793.576).

 

When I have this measure, I want to calculate the Weighted capacity by the formula: "KAP index" x "Actuals" : "Total Actuals"

(In above screendump the first line should calculate 87 * 327.760 : 114.793.576).

Hi @flunte70,

 

The problem is the way you are calculating your formula, giving it a max it will no sum all the values of the actuals you need to redo the formula like this:

 

Height =
DIVIDE (
    [KAP Index] * [Actuals],
    CALCULATE ( [Actuals], ALL ( Table[Nummer] ) )
)

I'm assuming that Actuals and KAP index are measures.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you very much for your time...

 

Unfortunately it still doesn't work; is it because both "Nummer" and "SC specifikation" is not measures and that we need to include the "SC specifikation" column?

 

By the way; I got an error with you formel an corrected ( Table[Nummer] ) to ( Data[Nummer] ) as "Data" is the name of the table.

 

21-12-2017 10-42-28.jpg

Hi @flunte70,

 

didn't know the name of your table that's why i put Table 😄

 

Place also in the ALL statement the SC specifikation.

 

regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



YES - thanks a lot, MFelix!; that soved the issue with calculating each row; so now I need to summarize all these values in the Total of this column in stead of using the same formula on the Total line...

 

22-12-2017 07-48-24.jpg

Hi @flunte70,

 

Create a new measure and use it on your column:

 

Height Total =
IF (
    HASONEVALUE ( Data[Nummer] ),
    [Height],
    SUMX ( ALL ( Data[Nummer], Data[SC specifikation] ), [Height] )
)

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



**bleep**, I forgot to test it when I use filter 😞

 

The measure:

TEST Vægtet KAP = IF ( HASONEVALUE ( Data[Nummer] ); DIVIDE ([KAP Index] * [Actuals]; CALCULATE ( [Actuals]; ALL ( Data[Nummer]; Data[SC specifikation] ))); SUMX ( ALL ( Data[Nummer]; Data[SC specifikation] );DIVIDE ([KAP Index] * [Actuals]; CALCULATE ( [Actuals]; ALL ( Data[Nummer]; Data[SC specifikation] ))) ) )

 

works when I look at all the records:

22-12-2017 11-03-06.jpg

 

but not if I apply a filter:

22-12-2017 11-03-44.jpg

 

The filter is based on a small table where I categorize "Nummer":

22-12-2017 11-09-39.jpg

 

MFelix - if you are not already tired of me - I hope that this is the last question regarding this issue 🙂

Hi @flunte70,

 

Try to make two formulas one for Heigth and another for total Height that uses the previous one. If try to make it a full dax measure the context will have to be changed.

 

Regards,

Mfelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix,

 

I have the flw:

?Height = CALCULATE ( [Actuals]; ALL ( Data[Nummer]; Data[SC specifikation] ) )

?Vægtet KAP OLD = DIVIDE ([KAP Index] * [Actuals]; CALCULATE ( [Actuals]; ALL ( Data[Nummer]; Data[SC specifikation] )))

?Vægtet KAP = IF ( HASONEVALUE ( Data[Nummer] ); [?Vægtet KAP OLD]; SUMX ( ALL ( Data[Nummer]; Data[SC specifikation] ); [?Vægtet KAP OLD] ) )

 

The ? before the name is to keap them in the top of my measures.

"?Height" is returning the Total for all rows which is ok when my "Kategori" filter is off.

I think that the problem with my filter is that it is in a different table as I thought I could enter it in the ALL formula.

"?Vægtet KAP OLD" is returning the weighted CAPS in all the rows but the total is wrong

"?Vægtet KAP" is returning the weighted CAPS in all the rows and the total is right - but not when I filter on "Kategori"?

22-12-2017 13-19-56.jpg

Thanks a lot MFelix - you have saved my ass 🙂

 

Merry Christmas & a Happy New Year to you and your family!

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.