Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I want a solution for the following scenario.
I have a table with names and percentages.
I want a power query to count the people who have scored 70% to 80%
Thank you
Power query
Hi @Snehal_123
We can create a measure to count number of peple scoring below the required condition.
the syntax would be like:
Measure= CALCULATE(COUNT(TABLE'PERCENTAGE'), FILTER(TABLE, TABLE(PERCENTAGE)<50%))
Input:
Name | Percentage |
A | 50.00% |
B | 23.00% |
C | 54.00% |
A | 62.00% |
B | 78.00% |
C | 93.00% |
A | 90.00% |
B | 34.00% |
C | 19.00% |
A | 44.00% |
B | 89.00% |
C | 77.00% |
A | 34.00% |
Desired Output:
Below 50% | 6 |
51% to 80% | 4 |
Above 80% | 3 |
Use this code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TczBDcAgDEPRXXxGFSUpIceWMSL2X6MiXHz88pMj8KKgXk/FKoEvo0nGPItmHNYbMRvEXIg5v4kSu52YKrHhxMyI7YP1Aw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Percentage = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Percentage", type number}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Category", each if [Percentage] <= 0.5 then "Below 50%" else if [Percentage] <= 0.8 then "51% to 80%" else "Above 80%"),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Category"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
#"Grouped Rows"
Replace Source{Percentage] appropriately
=List.Count(List.Select(Source[Percentage], (x)=>x>=0.7 and x<=0.8))