我有一个数据集,需要对其进行索引,直到名称和地址字段中出现空值,然后它会重置计数。如果为空,则该值应为零。我试图让索引看起来像这样:
姓名和地址 | 索引 |
---|---|
aasdfnkjdf | 1 |
aasdfnkjdf | 2 |
aasdfnkjdf | 3 |
空 | 0 |
空 | 0 |
aasdfnkjdf | 1 |
aasdfnkjdf | 2 |
空 | 0 |
空 | 0 |
空 | 0 |
aasdfnkjdf | 1 |
aasdfnkjdf | 2 |
空 | 0 |
aasdfnkjdf | 1 |
aasdfnkjdf | 2 |
名称和地址字段没有设置出现多少个空值的节奏。谢谢!
我尝试过做一个索引,然后对索引进行排名,但是没有规则的空间隔来使其工作
你可以在PQ试试这个
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkwsTknLy85KSVPSUTJUitVBEzLCFDIGCwEZBqgM4ozC1EeuAUQojwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Name and address" = _t, Index = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index.1", 1, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Table.RowCount( Table.SelectRows(#"Added Index",(x)=>x[Index.1]<=[Index.1] and x[Name and address] =""))+1),
Custom1 = Table.AddColumn(#"Added Custom", "Custom 1", each if [Name and address] = "" then 0 else if [Custom]=1 then Table.RowCount( Table.SelectRows(#"Added Custom",(x)=>x[Index.1]<=[Index.1] and x[Custom] =[Custom])) else Table.RowCount( Table.SelectRows(#"Added Custom",(x)=>x[Index.1]<=[Index.1] and x[Custom] =[Custom]))-1),
#"Removed Columns" = Table.RemoveColumns(Custom1,{"Index.1", "Custom"})
in
#"Removed Columns"