Forum Discussion
If Null Condition in Table.Group always failing
- 3 years ago
Hi Anonymous ,
For your first question, let me explain more about _[ItemPhotoName]{0}.
_ represent the all the tables you merged. You can modify the code like below to verify, click the Table cell,
You will see the contens in it.
_[ItemPhotoName] represent the [ItemPhotoName] column in the merged table. Also verify like this:
You can see it's a list instead of a value, to convert to a value, you should specify which row you want to get. For the ID 1002, there is only one row, the symbol {} can specify row in the list, {0} means the first row, {1} means the second row, and so on.
Modify the formula to verify:
2. You don't need to change the data type of the column, as I don't know the actually data, I give the solution according to situation.
If it's null:
= Table.Group(#"Changed Type", {"ID", "ItemName"}, {{"PhotoPerItemCount", each if _[ItemPhotoName]{0} = null then 0 else Table.RowCount(_)}})If it's "null":
= Table.Group(#"Changed Type", {"ID", "ItemName"}, {{"PhotoPerItemCount", each if _[ItemPhotoName]{0} = "null" then 0 else Table.RowCount(_)}})If it's blank:
= Table.Group(#"Changed Type", {"ID", "ItemName"}, {{"PhotoPerItemCount", each if _[ItemPhotoName]{0} = "" then 0 else Table.RowCount(_)}})Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
= Table.Group(#"Previous Table", {"ID", "ItemName"}, {{"PhotoPerItemCount", each List.NonNullCount([ItemPhotoName])}})wdx223_Daniel This seems to work, so thank you! But I'm unsure why it needs to be done this way, compared to my original solution?
Do you know?
- wdx223_Daniel3 years ago
Community Champion
this "each" bring in a group, which is grouped by the columns in the 2nd parameter.
so [ItemPhotoName] represent a list, and it can not compare to 0 directly, you need it iterate over every item in the list to compare to null, such as "List.Tranform([ItemPhotoName],each if _= null then 0 else 1"