The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
Solved! Go to Solution.
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.
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.
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)