Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ponchibonos
Frequent Visitor

Calculate percentages with filters and ponderate values

Hi community.

 

I have a table to which I want to calculate percentages depending on the filters I apply. The conditions for the filters are the columns “Nombre de la Organización, “Atributo”, “Ficha peguntas.EAS”. The value on which I want the percentage to be calculated is the column “Valor ponderado”.
The two characteristics that I have not been able to resolve are:
Not all records in “Valor ponderado” have the same values but can be 0,1, 2 or 3 so a simple formula of adding the values and dividing by the number of values does not work for me to calculate the percentage.
The other point is that there are records that have no response (null) so they should not be included in the percentage calculation.

I would like to know how to calculate the percentages to consider the records with different values (0, 1, 2 or 3) and not to consider the null values for the calculation.

The result would have to be that when you filter by “Nombre de la Organización, “Atributo”, “Ficha peguntas.EAS” the percentages are calculated.

Thank you very much.

Regards

Table with data 

 

 

ponchibonos_0-1737479891095.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ponchibonos 

Based on your needs, I have created the following table.

vjialongymsft_0-1737516283318.png


Then, you can ues the following measure to get the result you want:

Weight = IF(SELECTEDVALUE(Consultal[Valor Ponderado]) = 0 , 1 ,SELECTEDVALUE(Consultal[Valor Ponderado]))

 

Percentage = 
VAR FilteredValues =
    FILTER(
        'Consultal',
        NOT ISBLANK('Consultal'[Valor ponderado])
    )
VAR TotalSum =
    SUMX(FilteredValues, 'Consultal'[Valor ponderado])
VAR TotalCount =
    SUMX(FilteredValues, [Weight])
RETURN
    DIVIDE(TotalSum*100, TotalCount, 0)

 

 

Result:

vjialongymsft_1-1737516383654.png

 

 

Best Regards,

Jayleny

 

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

8 REPLIES 8
Sahir_Maharaj
Super User
Super User

Hello @ponchibonos,

 

Can you please try this approach:

Percentage Measure = 
VAR FilteredValues =
    FILTER(
        TableName,
        NOT ISBLANK(TableName[Valor ponderado])
    )
VAR TotalSum =
    SUMX(FilteredValues, TableName[Valor ponderado])
VAR TotalCount =
    COUNTAX(FilteredValues, TableName[Valor ponderado])
RETURN
    DIVIDE(TotalSum, TotalCount, 0)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Thanks for your answer @Sahir_Maharaj 

With some small modifications to your proposal I managed to solve the first problem I had, that of calculating the percentages considering only the cells with values.

 

 

ponchibonos_0-1737489892395.png

 

 

However, I have not been able to solve the second problem which is a formula to calculate the percentage considering the weighting of the answers.

 

 Some cases to clarify the idea based on the next table:

ponchibonos_1-1737489892399.png

 

Case 1. I make a filter to select by “# Question” and select question 5.

The result of the percentage formula above is 200 because (2+2)*100 / 2 = 200

Case 2. I make a filter to select by “Organization” and select “2”.

The result of the above percentage formula is 100 because (0+2+1+0+2)*100 / 5 = 100

However, there are two questions that had a value of “0”.

 

It should be noted that for each question there can only be three answers: null, 0 and depending on the weighting (1, 2 and 3). In other words, a question with a weighting of 3 could not have values of 1 or 2.

 

Thanks for your help.

 

Regards

Anonymous
Not applicable

Hi @ponchibonos 

What do you mean by this phrase: "a question with a weighting of 3 could not have values of 1 or 2".

Regarding the two cases you mentioned, what would the results be after applying the percentage calculation formula that takes into account the weight of the answers? Could you elaborate on this in detail so that I can better assist you?



 

 

 

 

Best Regards,

Jayleny

 

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

Thanks for your answer @Anonymous 

What I mean is that each question has three possible values. For example, question "1" can be null, 0, and 1. Question "5" can be null, 0, and 2. This difference is because I consider question "5" to be more important than question "1".

Anonymous
Not applicable

Hi @ponchibonos 

My understanding is that for the second example you mentioned above, the result you want is (0+2+1+0+2)*100 / 3 = 166.67 instead of (0+2+1+0+2)*100 / 5 = 100. Is my understanding correct? If I am mistaken, please point it out.

 

 

 

 

 

Best Regards,

Jayleny

 

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

In the case you mention.

I want is (0+2+1+0+2)*100 / 7  = 71.42 instead of (0+2+1+0+2)*100 / 5 = 100

 

7 Is because:

first register can be null, 0 or 1

Second register can be null, 0 or 2

Third register can be null, 0 or 1

Forth register can be null, 0 or 1

Fifth register can be null, 0 or 2.

 

That means the 100% would be 7 

 

Thanks in advance

 

 

Anonymous
Not applicable

Hi @ponchibonos 

Based on your needs, I have created the following table.

vjialongymsft_0-1737516283318.png


Then, you can ues the following measure to get the result you want:

Weight = IF(SELECTEDVALUE(Consultal[Valor Ponderado]) = 0 , 1 ,SELECTEDVALUE(Consultal[Valor Ponderado]))

 

Percentage = 
VAR FilteredValues =
    FILTER(
        'Consultal',
        NOT ISBLANK('Consultal'[Valor ponderado])
    )
VAR TotalSum =
    SUMX(FilteredValues, 'Consultal'[Valor ponderado])
VAR TotalCount =
    SUMX(FilteredValues, [Weight])
RETURN
    DIVIDE(TotalSum*100, TotalCount, 0)

 

 

Result:

vjialongymsft_1-1737516383654.png

 

 

Best Regards,

Jayleny

 

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

Excellent - anytime, happy to help!


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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