Nullable text?

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Book3
AB
1PositionRep
2HRJack
3SalesFred
4FinanceJack
5AdminPete
6MgtJack
7TrainingFred
8SecurityFred
9ITJack
Sheet1


let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Position", type text}, {"Rep", type text}}),
#"Grouped Rows" = #!"Table.Group(#""Changed Type"", {""Rep""}, {{""Count"", each [Rep], type list [Position=nullable text, Rep=nullable text]}})"
in
#"Grouped Rows"

Using PQ to return grouped by records, as in Jack HR, Finance, Mgt, IT
I get a Token comma expected message, I've tried inserting commas in various places but to no avail. When I remove the "[Position=nullable text, Rep=nullable text]" the command works and returns the grouped records.
What does the nullable text information come up as I haven't noticed it before? Where is the token comma supposed to go to make this work if I leave the nullable text info in?
 
Is that what you want?
Power Query:
Table.Group(Source, {"Rep"}, {{"Count", each List.Distinct([Position]), type list, [Position = type nullable text, Rep = type nullable text]}})
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
working M:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Rep"}, {{"Count", each List.Distinct([Position]), type list, [Position = type nullable text, Rep = type nullable text]}}),
    Extract = Table.TransformColumns(Group, {"Count",each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    Extract
 
Upvote 0
OK, I think we're one step closer to solving this, thanks Sandy for your work so far.
The method I use to group rows mainly because it cuts out a step is as per
You will see at approx 2:30 into the video that a change is required to move from Table to List. In the Youtube video there is no declaration of type (Text) following type Table.
For some reason, and I think only in the last 2 weeks PQ now declares the types and adds [Field = type text] or [Field = type nullable text] after type Table.
I've now tried to group rows on another computer and the declaration occurs there as well so something has changed on PQ, I thought originally I may have altered one of my settings but evidently this is not the case. Why do these declarations come up and can they be removed?
 
Upvote 0
Thank you Sandy, I have read the documentation, I'm still not sure why the method I've been using for a few months no longer works. If it's because of the Automatically detect data type I can't change this setting.
 
Upvote 0
in your example data type line (#"Changed Type") is "nullable" line so you can remove it at the beginning. In your case all data is a text so can be type text or type any and has no effect on the rest of the code except for increasing the number of lines.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Position", type text}, {"Rep", type text}}),
    #"Grouped Rows" = #!"Table.Group(#""Changed Type"", {""Rep""}, {{""Count"", each [Rep], type list [Position=nullable text, Rep=nullable text]}})"
in
    #"Grouped Rows"
You can turn it off here

datatype.png

unfortunately it works for current workbook but not for all workbooks in the future
or
remove this line each time you create new query if you are sure it is not necessary
 
Upvote 0
Power Query is the art of predicting what the result will be if you use a function and how it will affect the final result, not just typing a function like "maybe it will work"
practice, practice and practice again :biggrin: this is not Click&Go only
 
Upvote 0
T
Power Query is the art of predicting what the result will be if you use a function and how it will affect the final result, not just typing a function like "maybe it will work"
practice, practice and practice again :biggrin: this is not Click&Go only
Thanks Sandy for your help here. I agree with the practice but up until a few weeks ago my method for Grouping information worked fine and now without any change in my settings, it requires extra steps and an extra layer of understanding.
 
Upvote 0

Forum statistics

Threads
1,216,591
Messages
6,131,629
Members
449,658
Latest member
JasonEncon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top