Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Create new table with calculated field

Hi There, I have one table and I would like to make a second table which details the total number of medals per country as opposed to per athlete which is what I currently have.

 

The athelete table has the following columns which gives the total number of medals each athlete won:

 

Name - Nationality - Sport - Total Medals

 

I would like to make a second table which has the total number of medals per country so it would like this:

 

Country - Total Medals

 

I am not sure how to calculate this and make the new table, I am new to Power BI so any help would be much appreciated. Thanks.

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous ,

     

    Please try SUMMARIZE() function.

    https://docs.microsoft.com/en-us/dax/summarize-function-dax

     For example:

    Table

    DAX

     

    Table 2 = SUMMARIZE('Table','Table'[Nationality],"Total Medals",SUM('Table'[Total Medals]))

     

     Table 2

     

    Best Regards,

    Jay

    Community Support Team _ Jay Wang

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

4 Replies

  • Hi Anonymous ,

     

    You don't need to create a new table, calculations on visualizations on PBI are created according to ocntext so if you add the natitonality and the Total medals to your visualization you will have the result according to contry no need to add additional data to your model.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I have tried that however as the total number of medals is linked to the athlete when I select countries and total medals for the visualisation I end up with duplicate countries as more than one athlete from that country has won a medal. 

  • In visualization, you can use a table and or Matrix and Drag Country and Sum of the medal.  That will give you the answer

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try SUMMARIZE() function.

    https://docs.microsoft.com/en-us/dax/summarize-function-dax

     For example:

    Table

    DAX

     

    Table 2 = SUMMARIZE('Table','Table'[Nationality],"Total Medals",SUM('Table'[Total Medals]))

     

     Table 2

     

    Best Regards,

    Jay

    Community Support Team _ Jay Wang

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