Is it possible to create named constants in Power Query

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
I'm wondering if it's possible to create your own named constants in PQ, like Order.Ascending (which equals 0) and Order.Descending (which equals 1)?

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Just to clarify what I'm looking for: I want to create a custom function with an optional parameter, very much like Table.Sort where Order.Ascending and Order.Descending are optional, and the default is Order.Ascending.

Further, I want this optional parameter to be restricted in such a way that an invalid entry cannot be made without an error, so the user will know immediately if the optional parameter they entered was valid.

So similar to how Table.Sort(Source, {{"Column1", Order.ABCDE}) will result in an error because Order.ABCDE isn't a valid entry. I want my optional parameter to be something like DisplayMode.KeyAndText or DisplayMode.TextAndKey and those should be the only two available options, with the default being DisplayMode.KeyAndText.

Thanks
 
Upvote 0
Kind of spit balling here but have you tried integrating a custom list into your parameterized logic?

={[Option=0,Desc="Order.Ascending"],[Option=1,Desc="Order.Descending"]}
 
Upvote 0

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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