The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
What is the correct syntax or a similar method to achieve a countif with a fixed reference at the first row
=COUNTIF(M$1:$M3,M3)
As you can see this formula expands as the row progresses... but how do I do it in M?
Solved! Go to Solution.
First add an index column. Next add a column that pulls the M column from the #"Added Index" step and use List.Select to pull all values matching M (of the current step). Use List.Count to count the number of rows. Now you can remove the INdex column. Query is below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1YlWSgKTyWAyEYmEi8QCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [M = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1),
AddCountIf = Table.AddColumn(#"Added Index", "CountIf", each List.Count(List.Select(List.FirstN(#"Added Index"[M],[Index]), (el) => el = [M]))),
#"Removed Columns" = Table.RemoveColumns(AddCountIf,{"Index"})
in
#"Removed Columns"
First add an index column. Next add a column that pulls the M column from the #"Added Index" step and use List.Select to pull all values matching M (of the current step). Use List.Count to count the number of rows. Now you can remove the INdex column. Query is below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlSK1YlWSgKTyWAyEYmEi8QCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [M = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1),
AddCountIf = Table.AddColumn(#"Added Index", "CountIf", each List.Count(List.Select(List.FirstN(#"Added Index"[M],[Index]), (el) => el = [M]))),
#"Removed Columns" = Table.RemoveColumns(AddCountIf,{"Index"})
in
#"Removed Columns"
User | Count |
---|---|
79 | |
78 | |
37 | |
33 | |
31 |
User | Count |
---|---|
93 | |
81 | |
59 | |
49 | |
49 |