Forum Discussion
Calculate percentage on direct query
Hi all (:
I would appreciate your help.
I want to calculate a percentage on direct query.
I calc the count(*) "country" and I an not succeed to calculate the percentage
The data :
Country color of the flag
--------------------------------
USA red
USA white
USA blue
Greece White
Greece blue
The The desired result:
Country sum(count()) Percent%
USA 3 60%
Greece 2 40%
Thanks,
sin
Hi Anonymous
A little change based Rocco_sprmnt21 query, delete *100, after close &&apply, change the data column to "percentage" format.
Also, since it is direct query mode, you could also try to create a measure like:
Measure 3 = CALCULATE ( COUNT ( 'Table 2'[color of flag] ), ALLEXCEPT ( 'Table 2', 'Table 2'[Country] ) ) / CALCULATE ( COUNT ( 'Table 2'[color of flag] ), ALL ( 'Table 2' ) )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
try somethink like this:
grp= Table.Group(tab, {"Country "}, {{"Conteggio", each Table.RowCount(_), type number}}),
pc = Table.AddColumn(grp, "Percentuale di", each [Conteggio] / List.Sum(grp[Conteggio]) * 100, type number) - v-juanli-msft
Community Support
Hi Anonymous
A little change based Rocco_sprmnt21 query, delete *100, after close &&apply, change the data column to "percentage" format.
Also, since it is direct query mode, you could also try to create a measure like:
Measure 3 = CALCULATE ( COUNT ( 'Table 2'[color of flag] ), ALLEXCEPT ( 'Table 2', 'Table 2'[Country] ) ) / CALCULATE ( COUNT ( 'Table 2'[color of flag] ), ALL ( 'Table 2' ) )Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.