Forum Discussion

nok's avatar
nok
Advocate II
1 year ago
Solved

Create weighted calculation in a visual table

Hello,

I have two different measures in my visual table: qtd_itens and run_fx, which perform their respective calculations per Buyer in my visual table.

I want to create a new column in this visual table that would be the value of a measure that does what the image below exemplifies:

 

This new measure would be:
divide the qtd_itens of the buyer in that row by the total qtd_itens and then take this result and multiply it by the run_fx of that buyer.

 

How can I make this measure so that it works in my visual table?

  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for the reply from lbendlin , please allow me to provide another insight:

    Hi, nok 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the measure I've created for your needs:

    Measure = 
    VAR to1=CALCULATE([qtd_itens],ALLSELECTED('Table'))
    VAR c1=[qtd_itens]
    VAR c2=[run_fx]
    RETURN DIVIDE(c1,to1)*c2

    3.Here's my final result, which I hope meets your requirements.

    As our qtd_itens and run_fx measures may differ, I cannot guarantee that my code will fully meet your requirements. I recommend adjusting it according to your actual measures.

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from lbendlin , please allow me to provide another insight:

    Hi, nok 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the measure I've created for your needs:

    Measure = 
    VAR to1=CALCULATE([qtd_itens],ALLSELECTED('Table'))
    VAR c1=[qtd_itens]
    VAR c2=[run_fx]
    RETURN DIVIDE(c1,to1)*c2

    3.Here's my final result, which I hope meets your requirements.

    As our qtd_itens and run_fx measures may differ, I cannot guarantee that my code will fully meet your requirements. I recommend adjusting it according to your actual measures.

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

    • nok's avatar
      nok
      Advocate II

      Simply amazing! This is exactly what I wanted to do.

      Thank you very much, Anonymous 

  • Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

    Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

    Please show the expected outcome based on the sample data you provided.

    Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523