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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
EHP
Advocate I
Advocate I

How necessary are the “as <type>” variable declarations in Power Query / M-Language?

I have this code excerpt:

 

GetPlanningItemChangeMarkersData = (environmentName as text, planningItemId as number) as record =>

 

which appears to behave the same way as:

 

GetPlanningItemChangeMarkersData = (environmentName, planningItemId) =>

 

Are either of these better practice than the other? I could see an argument that it's much quicker to see what GetPlanningItemChangeMarkersData will return if I leave the "as record" declaration in there, but environmentName and planningItemId are obviously going to be text and a number, so surely I could leave them out?

 

Currently I'm going to go with

 

GetPlanningItemChangeMarkersData = (environmentName, planningItemId) as record => 

 

, but I'd love to hear the community opinions on this.

 

TIA.

1 ACCEPTED SOLUTION
mpicca13
Resolver IV
Resolver IV

Its possible that not putting "as" could lead to the column being identified as either text or whole number which will be indicated by the top of the column showing "abc/123"

This could lead to additional applied steps to be made if you have to change it specifically to text or whole number. My opinion is best practice would be to put "as" wherever a specific data type is needed.

View solution in original post

1 REPLY 1
mpicca13
Resolver IV
Resolver IV

Its possible that not putting "as" could lead to the column being identified as either text or whole number which will be indicated by the top of the column showing "abc/123"

This could lead to additional applied steps to be made if you have to change it specifically to text or whole number. My opinion is best practice would be to put "as" wherever a specific data type is needed.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors