Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Creating ratio measure

Hi. These are my data structure and table. I would like to create a ratio column to show each country's ratio in the total import or export. How can I do it?

 

 

1 Reply

  • Hi,

    I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

    I tried to create a sample pbix file like below.

     

     

    TotalExp: = 
    SUM('Ex-Imp'[Export] )

     

    TotalImp: = 
    SUM('Ex-Imp'[Import] )

     

    Export Ratio by grandtotal: = 
    VAR _allcountry =
        CALCULATE ( [TotalExp:], ALL ( Country[Country] ) )
    RETURN
        DIVIDE ( [TotalExp:], _allcountry )

     

    Import Ratio by grandtotal: = 
    VAR _allcountry =
        CALCULATE ( [TotalImp:], ALL ( Country[Country] ) )
    RETURN
        DIVIDE ( [TotalImp:], _allcountry )