Forum Discussion

NelsonDíaz1's avatar
NelsonDíaz1
Frequent Visitor
3 years ago
Solved

Total percentages

I have this data:

CountryFórmulaGTR 23
Costa RicaAdorlan147.305
Costa RicaZaldiar696.783
El SalvadorAdorlan110.572
El SalvadorZaldiar552.542
GuatemalaAdorlan292.941
GuatemalaZaldiar408.122

 

And I got this results:

My problem is with the percentages. The thing is that I need that the total in every Country be the result of the Total divided by the total of the Country. What I mean nomerically is, for example; Costa Rica = 844.088/2.208.265 = 38.22%, but keeps the percentages of the products (Adorlan in Costa Rica it is 17.45 that is the result of divide 147.305/844.088.

Is it possible?

 

Im working with:

Total GTR 23 = SUM('Hoja1'[GTR 23])
Totales por País = CALCULATE([Total GTR 23],ALL(Hoja1[Fórmula]))
%País = DIVIDE([Total GTR 23],[Totales por País])
 
I tried adding Hoja1[Country] in Totales por País, but is not the result that I needed, because it divides 147.305/2.208.265
 
I would appreciate your help.
Thanks
  • Hi, NelsonDíaz1 

    try below  just adjust your table and column name

    % =
    var a = CALCULATE(SUM(country[gtr 23]),REMOVEFILTERS(country[Country]))
    var b = CALCULATE(SUM(country[gtr 23]),REMOVEFILTERS(country[Fórmula]))
    var c =SWITCH(TRUE(),
    ISINSCOPE(country[Fórmula]),DIVIDE(SUM(country[gtr 23]),b),
    ISINSCOPE(country[Country]),DIVIDE(SUM(country[gtr 23]),a)
    )
    return
    c
     

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

2 Replies

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    Hi, NelsonDíaz1 

    try below  just adjust your table and column name

    % =
    var a = CALCULATE(SUM(country[gtr 23]),REMOVEFILTERS(country[Country]))
    var b = CALCULATE(SUM(country[gtr 23]),REMOVEFILTERS(country[Fórmula]))
    var c =SWITCH(TRUE(),
    ISINSCOPE(country[Fórmula]),DIVIDE(SUM(country[gtr 23]),b),
    ISINSCOPE(country[Country]),DIVIDE(SUM(country[gtr 23]),a)
    )
    return
    c
     

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