Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

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

 

 
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
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' )
    )

Capture8.JPG

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.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
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' )
    )

Capture8.JPG

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.

Anonymous
Not 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)

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors