如果值为空,则电源查询索引重置

问题描述 投票:0回答:1

我有一个数据集,需要对其进行索引,直到名称和地址字段中出现空值,然后它会重置计数。如果为空,则该值应为零。我试图让索引看起来像这样:

姓名和地址 索引
aasdfnkjdf 1
aasdfnkjdf 2
aasdfnkjdf 3
0
0
aasdfnkjdf 1
aasdfnkjdf 2
0
0
0
aasdfnkjdf 1
aasdfnkjdf 2
0
aasdfnkjdf 1
aasdfnkjdf 2

名称和地址字段没有设置出现多少个空值的节奏。谢谢!

我尝试过做一个索引,然后对索引进行排名,但是没有规则的空间隔来使其工作

excel powerquery
1个回答
0
投票

你可以在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"

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.