Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gavin007
Helper V
Helper V

invalid identifier for list.sum syntax

Hi, I use group by window to sum Rev Act and GM Act by InvoiceDate and OrderNo_Revised_Item. it all works well until I try to amend the sum of Rev Act by applying a condition in when evaluating the source, which is [I/C]="C". (highlight in bold), I got an error message like invalid identifier.

 

= Table.Group(Source, {"InvoiceDate", "OrderNo_Revised_Item"}, {{"Ext Rev Act", each List.Sum(Table.SelectRows(Source, each [I/C]="C") [Rev Act]), type nullable number}, {"GM Act", each List.Sum([GM Act]), type nullable number}})

 

Capture.PNG

 

I couldn't figure out what is wrong with that. Can anyone help?

1 ACCEPTED SOLUTION

Hi @gavin007 ,

yes, I didn't pay attention to the other code. Problem is, that you have used the "each"-keyword twice and now the syntax sugar doesn't know what to refer to.

Therefore I'd recommend to transform at least one of the functions to the explicit syntax:

 

Table.Group(Source, {"InvoiceDate", "OrderNo_Revised_Item"}, {{"Ext Rev Act", each List.Sum(Table.SelectRows(Source, (row) => row[#"I/C"]="C") [Rev Act]), type nullable number}, {"GM Act", each List.Sum([GM Act]), type nullable number}})

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

8 REPLIES 8
Greg_Deckler
Super User
Super User

@ImkeF , @edhans 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @gavin007 

that's probably due to the special characters in the field name. Try to escape it like so: [#"C/O"].

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF It partialy work but it then it has error message like "We cannot convert the value 380000 to type Function."

Is there something wrong with the type?

Hi @gavin007 ,

yes, I didn't pay attention to the other code. Problem is, that you have used the "each"-keyword twice and now the syntax sugar doesn't know what to refer to.

Therefore I'd recommend to transform at least one of the functions to the explicit syntax:

 

Table.Group(Source, {"InvoiceDate", "OrderNo_Revised_Item"}, {{"Ext Rev Act", each List.Sum(Table.SelectRows(Source, (row) => row[#"I/C"]="C") [Rev Act]), type nullable number}, {"GM Act", each List.Sum([GM Act]), type nullable number}})

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

@ImkeF That is awsome. It is working perfecly. Can i humbly ask how and where can i learn this syntax? I am good with click and drop but when it comes to scripting,  expecially with the M language structue, i find it difficult to write a script like that.

Hi @gavin007 ,

glad to hear that it worked for you.

I've collected some learning resources here: https://www.thebiccountant.com/learning-resources/ 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

hi @gavin007 

 

 

I wonder if you wanted to add [Rev Act] for the entire Source table or just for each sub-group.
In the latter case, you should replace Source with _.

then from

 Table.SelectRows(Source, each [I/C]="C") [Rev Act])

to

Table.SelectRows(_, each [I/C]="C") [Rev Act])

 

 

In general, for faster and more useful help you should provide the expected and the input data and if any error appears in your code, the complete copy of the code used.

 

@Anonymous that actual help. Many Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors