Forum Discussion
Snehal_123
3 years agoFrequent Visitor
Measure to count people scoring below 50 %
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
5 Replies
- Vijay_A_VermaMost Valuable Professional
Replace Source{Percentage] appropriately
=List.Count(List.Select(Source[Percentage], (x)=>x>=0.7 and x<=0.8)) - Mahesh0016Super User
Snehal_123 can you please share your EndOutPut?
- Snehal_123Frequent Visitor
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 - Vijay_A_VermaMost Valuable Professional
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"
- mukeshkasi25Frequent Visitor
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%))