停胎是什么原因造成的| 叶公好龙的好是什么意思| 家慈是什么意思| loves是什么意思| bmd是什么意思| 面瘫是什么| 为什么会得血管瘤| ic50是什么意思| ny什么牌子| 壬水是什么水| 同型半胱氨酸高挂什么科| 猫字五行属什么| 脖子上长小肉疙瘩是什么原因| 内分泌代谢科是看什么病的| 人乳头病毒是什么意思| 如夫人是什么意思| 血管瘤有什么危害吗| 商朝后面是什么朝代| 左侧头皮发麻是什么原因| 逍遥丸主治什么病| 吃什么瘦肚子脂肪最快| 祛风是什么意思| 静脉曲张挂什么科| 茶毫是什么| 老人家头晕是什么原因| 把头是什么意思| 红颜知己是什么关系| 力是什么| 加湿器有什么用| 脊髓灰质炎是什么病| 喝酒手麻是什么原因| 荣辱与共是什么生肖| 为什么不建议做融合手术| 胸部中间痛什么原因引起的| 茄子有什么营养| warning什么意思| 泌尿感染吃什么药最好| 肝异常一般是什么情况| 吃什么水果美白| 奴才模样是什么生肖| 脚上长痣代表什么| 哀大莫过于心死是什么意思| 淡墨是什么意思| 止咳化痰吃什么药| 圣灵是什么意思| 做爱女生什么感觉| 梦见奶奶死了是什么意思| 励志是什么意思| 拉尿有泡沫是什么原因| 骨质疏松检查什么项目| 热病是什么病| 脸部出油多是什么原因| 猫藓用什么药| dha什么牌子最好最安全| 男人的精子对女人有什么好处| 睡觉咬牙齿是什么原因引起的| 黄加黑变成什么颜色| 中水是什么意思| 什么是事业编| 黄芪什么人不能喝| 静怡是什么意思| May什么意思| 茶学专业学什么| 吃什么可以快速减肥| 女上位是什么意思| 墙头草是什么意思| yuri是什么意思| 宝妈男是什么意思| 被蝎子蛰了用什么药| 痛风用什么药| 心影不大是什么意思| 什么补肾最好| 淼是什么意思| 蜘蛛吃什么食物| 清朝前面是什么朝代| 什么是凌汛| 代孕是什么| 带状疱疹能吃什么| 宋朝之后是什么朝代| havva是什么牌子| 3月5号是什么星座| 四肢肌力5级什么意思| 胆结石吃什么比较好| 脾胃不好吃什么食物好| 最大的恐龙是什么恐龙| 生蚝和牡蛎有什么区别| 什么布料| 傲娇是什么意思| 建档是什么意思| 六字箴言是什么意思| 心率过速吃什么药| 委屈是什么意思| 降钙素是查什么的| 什么是毛囊炎| 什么是子宫憩室| landrover是什么车| 虬角为什么要染成绿色| 个子矮吃什么才能长高| 胃酸的主要成分是什么| 疱疹吃什么药见效快| 子宫脱落是什么原因引起的| 三叉神经痛用什么药| 爱趴着睡觉是什么原因| 尖嘴猴腮什么意思| 骨蒸是什么意思| 昆虫记是什么类型的书| mm表示什么| 1980属什么生肖| 中国最大的湖泊是什么湖| 稻谷是什么| 梦见老鼠是什么征兆| 世界上最难写的字是什么| 糖尿病能喝什么饮料| 人流后吃什么水果| 嘴角裂口是什么原因怎么办| 白血病是什么症状| 什么叫肺纤维化| 海关清关什么意思| 阴囊湿疹用什么药膏| 子宫肌瘤钙化是什么意思| 生水是什么意思| nu11是什么意思| 嘴上起泡是什么原因| 男人脚底发热是什么病| spi是什么| 窦性心律t波改变是什么意思| 望尘莫及什么意思| 一个草字头一个见念什么| 拉黄水是什么原因| 去医院看脚挂什么科| 吃什么东西养胃| 北洋军阀是什么意思| tpc是什么意思| 尿蛋白十一什么意思| 满江红是什么植物| 骇人是什么意思| 无脑是什么意思| 什么人不能吃石斛| 咳嗽吃什么食物好得最快最有效| t11椎体在什么位置| 尿蛋白2十吃什么药| chloe什么牌子| 聚酯纤维是什么材料| 4.23是什么星座| 杜甫被人们称为什么| 什么是什么的眼睛| 干咳吃什么药| 道是什么意思| 东北有什么特产| s和m是什么| 囊肿是什么引起的| 龟兔赛跑的故事告诉我们什么道理| 曾孙是什么意思| 肝经湿热吃什么中成药| 苯三酚注射有什么用| 上海五行属什么| 闭日是什么意思| 樱桃补什么| 胃肠彩超能检查出什么| 淀粉酶测定是查什么| 额头青筋凸起是什么原因| 煮方便面什么时候放鸡蛋| 狗狗生产需要准备什么| maybach是什么车| 左眼一直跳是什么原因| 什么是不动产权证| 主心骨是什么意思| 消融术是什么手术| 毓读什么| 甲醛是什么气味| 3月5日是什么纪念日| 什么花是绿色的| 缺镁吃什么食物补充最快| 伯爵是什么意思| 吃什么水果能降血压| 使婢差奴过一生是什么意思| 劫是什么意思| 神经疼是什么原因| 商朝后面是什么朝代| 水落石出是什么意思| 为什么近视不可逆| 什么叫碳水化合物| 夏天适合种植什么蔬菜| 气血不足什么症状| kg是什么单位| 尿液茶色是什么原因| 虫草有什么功效| 肚子左侧是什么器官| 为什么手比脸白那么多| 为什么不要看电焊火花| 月经前一周失眠是什么原因| 女性缺镁有什么症状| 1月23号什么星座| 胃痉挛什么症状| 金今念什么| 打卤面都有什么卤| 天相是什么意思| 隐是什么意思| 渐入佳境什么意思| 吃什么对心脏供血好| 正常精液是什么颜色| 歹且念什么| 肚子大是什么原因造成的| t11椎体在什么位置| 共青团书记是什么级别| 羁什么意思| 血管瘤吃什么药| 吃什么药可以推迟月经| 泡茶用什么杯子最好| 伞裙搭配什么上衣| 好学不倦什么意思| 再接再厉是什么意思| 什么是环境影响评价| 乳糜血是什么意思| 夏天是什么| 岛屿是什么| 尿潴留是什么症状| 梦到装修房子是什么征兆| 二月底是什么星座| 甲沟炎用什么药膏好| 双性恋是什么| 古代四大发明是什么| 什么是有意义的东西| 肛门跳动是什么原因| 肿瘤标志物cA724高说明什么| 蒸蒸日上什么意思| 高兴的什么| 诈骗是什么意思| 方脸适合什么耳环| 梨的功效与作用是什么| 作古是什么意思| 代肝是什么意思| 啤酒加味精有什么作用| 开瑞坦是什么药| 脸红什么| 艾滋病阳性是什么意思| 洋葱有什么功效与作用| 甲状腺炎是什么引起的| 慢性浅表性胃炎伴糜烂吃什么药| happy halloween是什么意思| 九加虎念什么| 咖啡加什么最好喝| 偏瘫是什么意思| 1996年属什么生肖| 什么时候最热| 9月出生的是什么星座| 今年83岁属什么生肖| 求租是什么意思| 古曼童是什么| 丝芙兰是什么品牌| 脚指甲变白是什么原因| 心肌炎是什么| ps医学上是什么意思| 吃什么可以祛痘排毒| 好饭不怕晚什么意思| gpr是什么意思| usim卡是什么卡| 夸加包念什么| 唐僧是什么佛| 天天吃玉米有什么好处和坏处| 梦见卖东西是什么意思| 小狗感冒了吃什么药| 手脚不协调是什么原因| 慢性非萎缩性胃炎伴糜烂是什么意思| 百度

Blog Post

Excel Blog
9 MIN READ

惠普EliteBook 830 G5评测:无可挑剔的商务笔记本惠普商务本一键防窥

Brian Jones (OFFICE)'s avatar
Dec 03, 2020
百度 二是坚持抓典型、建制度,持之以恒整治“四风”转变作风。

Today we are releasing to our Beta customers a new capability that will revolutionize how you build formulas in Excel. Excel formulas are the world’s most widely used programming language, yet one of the more basic principles in programming has been missing, and that is the ability to use the formula language to define your own re-usable functions.

 

=LAMBDA

Simply put, LAMBDA allows you to define your own custom functions using Excel’s formula language. Excel already allows you to define custom functions, but only by writing them in an entirely different language such as JavaScript.  In contrast, LAMBDA allows you to define a custom function in Excel’s own formula language.   Moreover, one function can call another, so there is no limit to the power you can deploy with a single function call. For folks with a computer science background, you’re probably already familiar with the concept of lambdas, and the introduction of LAMBDA makes the Excel formula language Turing Complete...

 

Reusable Custom Functions

With LAMBDA, you can take any formula you’ve built in Excel and wrap it up in a LAMBDA function and give it a name (like “MYFUNCTION”). Then anywhere in your sheet, you can refer to MYFUNCTION, re-using that custom function throughout your sheet. I’ll show a couple examples below.

 

Recursion 

Reusable functions is reason enough to start taking advantage of LAMBDA, but there’s one more thing… you can do recursion. If you create a LAMBDA called MYFUNCTION for example, you can call MYFUNCTION within the definition of MYFUNCTION. This is something that before, was only possible in Excel through script (like VBA/JavaScript). I’ll also show an example below of how you can leverage this to build things that were not possible before without writing script.

 

Reusable Custom Functions

One of the more challenging parts of working with formulas in Excel is that you often get fairly complex formulas that are re-used numerous times through the sheet (often by just copy/pasting). This can make it hard for others to read and understand what’s going on, put you more at risk of errors, and make it hard to find and fix the errors. With LAMBDA, you have re-use and composability. Create libraries for any pieces of logic you plan to use multiple times. It offers convenience and reduces the risk of errors.

 
Station IDs

For example, imagine I have a list of station IDs, where the state is encoded in the ID, and I want to pull that value out:

 

 

There are many ways to do this with Excel functions, here’s how I did it (I’m sure many of you have much more efficient ways to doing this… forgive me… I know for example the team would remind me I should take advantage of the LET function)

 

=LEFT(RIGHT(B18,LEN(B18)-FIND("-",B18)),FIND("-",RIGHT(B18,LEN(B18)-FIND("-",B18)))-1)

If I take that formula and copy it down the column, I can get the results shown in the table above.

 

There are two challenges with this approach:

  • Errors - If I find an error in my logic that I need to fix, I have to go back and update it everywhere it was used, and I might miss some. Additionally, there’s added risk whenever you have complex formulas repeated over & over again as opposed to defined just once and then referenced. If for example, there are some station IDs that look like this “105532-872332-WA-73”, my formula would not work with those. If I find this error and want to fix it, I then need to go back to every cell where I used that logic and update it.
  • Composability/Readability - If I’m not the original author, it’s hard to know what the intention of that formula is (to pull out the location). It’s also hard to use this logic in combination with other logic, like if I want to take the station ID and do a lookup based on the calculated location.

Using LAMBDA, I can create a function named GETLOCATION, and put the formula logic in the definition for that function.

 

=GETLOCATION

 

=LAMBDA(stationID, LEFT(RIGHT(stationID,LEN(stationID)-FIND("-",stationID)),FIND("-",RIGHT(stationID,LEN(stationID)-FIND("-",stationID)))-1))

Notice I specify the arguments my function will take (in this case stationID) and the logic for my function. Now in my spreadsheet, I can simply write GETLOCATION as a formula and reference the cell that has the stationID, just like any other Excel function. If I notice I have an error, I fix it in one place, and everywhere that uses that function is fixed.

 

 

Another added benefit, is that I can now compose that function with additional logic. For example, if I had a table of tax rates for each location, I could write this simple formula to return the rate based on the stationID.

 

=XLOOKUP(GETLOCATION(B18), table1[locations], table1[tax]).

 

OK, lot’s more to drill into here around how you can use this capability to build up a rich set of function libraries, make your sheets easier to understand and less error prone, etc. These functions can even take data types as arguments. We’ll post an example later of a custom function that takes two cities as input and calculates the distance between them using the geo coordinates and the radius of the earth to perform the calculation.

 

Let’s shift into the other big impact this will have on what you can build in Excel. This one is a bit more complex, but is pretty revolutionary for us… recursion.

 

Recursion

One of the big missing pieces in Excel formulas has been the ability to loop… to repeat over a set of logic at a dynamically defined interval. There are ways that you can manually configure the interval at which Excel recalculates to mimic this to an extent, but it’s not inherent to the formula language. That changes with LAMBDA.

 

Let’s take an example, albeit a bit contrived, but it’s a simple way to get the point across.

Imagine I have a set of strings, and I want to specify which characters should be removed from those strings dynamically:

 

 

Because the set of characters you’re specifying are not static, there really isn’t any good way of doing this. If you knew it was always a fixed set of characters, you could do a ton of nested logic, but that would be pretty complex and error prone to author. Not to mention, if the number of characters to be removed was larger than what you’d accounted for, it would fail.

 

With LAMBDA, we can create a function called REPLACECHARS that references itself allowing you to iterate over the list of characters to be removed:

  

=REPLACECHARS

=LAMBDA(textString, illegalChars,
     IF(illegalChars="", textstring,
       REPLACECHARS(
       SUBSTITUTE(textString, LEFT(illegalChars, 1), ""),
       RIGHT(illegalChars, LEN(illegalChars)-1)
)))

Notice that in the definition of REPLACECHARS, there is a reference to REPLACECHARS. The IF statement says if there are no more illegal characters, return the input textString, and otherwise remove each occurrence of the leftmost character in illegalChars. Recursion kicks in with the request to call REPLACECHARS again with the updated string, and the rest of illegalChars. This means it will keep calling itself until it has parsed over every character to be removed, giving the desired result.

 

 

Not just numbers & strings

If you’ve been following the Excel improvements over the past couple years, you probably noticed two significant improvements with the type of data you can work with in Excel:

  • Dynamic arrays - Rather than passing a single value into a function, you can pass an array of values, and functions can also return arrays of values. You can learn more about arrays here.
  • Data Types – The value stored in a cell is no longer just a string or a number. A single cell can contain a rich data type, with a large set of properties. You can learn more about data types here.

Functions can take data types and arrays as arguments, and they can also return results as data types and arrays. The same is true with the lambdas you build.

 

Let’s take an example... I have a list of cities, and I want to calculate the total distance I’d travel if I were to go to each city in order.

 

We’ll post the code for this one in a later post, but it’s pretty basic:

  • We have an array of City data types. The city data type has the latitude & longitude properties.
  • With latitude & longitude, we can do some basic math using the radius of the earth to approximate the distance between two points (that’s the first Lambda we call DistanceBetweenCities)
  • We create a recursive lambda, DistanceBetweenMultipleCities, to iterate over the cities in the array. In addition to calling itself, to iterate over the list of cities, it also calls the DistanceBetweenCities function to get a running total of the distance traveled.

 

Try it yourself

If you are in our Beta program, you can try it now yourself. We’d love your feedback as we continue to improve on this new capability.

 

Note: The lambda function is available to members of the Insiders: Beta program running Windows and Mac builds of Excel. Learn more about how to become an Insider here

 

LAMBDA Overview

There are three key pieces of =LAMBDA to understand:

  1. LAMBDA function components
  2. Naming a lambda
  3. Calling a lambda function

 

LAMBDA function components

Let’s look at an example which creates a basic lambda function.

 

Suppose we have the following formula:

=LAMBDA(x, x+122)

In this, x is the argument you can pass in when calling the LAMBDA, and x+122 is the logic.

 

For example, suppose you called the lambda and input the value 1 for x, Excel would do the following calculation:

1 + 122

Which, as we all know:

1 + 122 = 123

But how do you use these? If you've been pasting our examples into Excel, you may have noticed some #CALC! errors. To resolve those, you'll need to learn the next step.

 

Naming a lambda

To give your LAMBDA a name so it can be re-used, you will want to make use of the Name Manager.

 

The Name Manager can be found in the Ribbon by going to:

Formulas > Name Manager

 

Once you open the Name Manager you will see the following window

 

From this point you’ll want to create a new entry (New…) and fill out the associated fields

Name: The Name of your function

Comment: A description and associated tooltip which will be shown when calling your function

Refers to: Your lambda function definition

 

Once you’re done, you can hit “OK” to store your lambda and you should see the definition returned in the resultant window.

And that’s it! Now you can make use of your newly crafted custom function in the workbook by calling it by its name. 

 

Calling LAMBDA

To put it simply, you call a lambda function the same way you call native functions in Excel.

 

To illustrate this, lets revisit the previous example and show how to call MYLAMBDA with a value.

=MYLAMBDA(122)

Which of course returns the value:

123

One last thing to note, is that you can call a lambda without naming it. If we hadn’t named the previous formula, and just authored it in the grid, we could call it like this:

=LAMBDA(x, x+122)(1)

This passes in 1 for x, which returns

123

 

Just the beginning... join us for the journey

As you’ve probably noticed, we are improving the product on a regular basis. The desktop version of Excel for Windows & Mac updates monthly, and the web app much more frequently than that. We have a ton of improvements already planned for LAMBDA, but we’re looking to you for feedback along the way. One that I can tell you gets me every time is the experience of editing in the name manager... definitely lots of room for improvement there. We’ll also add some more array manipulation functions in the coming months that will help you build even more powerful lambdas taking more advantage of dynamic arrays.

 

Office Insiders

Join the Office Insider Program and choose the Beta Channel to get early access to LAMBDA in Excel. 

 

To give feedback and suggestions, click Help > Feedback, and Add #LAMBDA in your feedback so that we can easily find input about the feature. You can also post in the Excel Tech Community.

 

Connect with us

Stay connected with us.  Join our Excel Tech Community and check out this LAMBDA sample. Let us know what you think and we’d love to see what you build with LAMBDA!

 

Learn more

To learn more about LAMBDA, please check out our help article and in the meantime we are excited to hear more from you about the LAMBDA formulas you have created!

 

LAMBDA Help

Updated Dec 03, 2020
Version 4.0
悲伤是什么意思 排尿少是什么原因 2017年属鸡火命缺什么 梦见别人掉牙齿是什么征兆 三合是什么意思
六月属什么生肖 今年的属相是什么生肖 boss是什么意思 吃西红柿有什么好处 n2是什么意思
大便潜血什么意思 nb是什么意思 品相是什么意思 er什么意思 肝郁血虚吃什么中成药
什么言 血管瘤是什么样子图片 为什么来我家 睡美人最怕得什么病 太阳穴痛什么原因
4级手术是什么意思jasonfriends.com 匚读什么baiqunet.com 咳嗽痰多吃什么药hcv7jop4ns8r.cn 仓鼠为什么吃自己的孩子hcv8jop8ns2r.cn cph是什么意思hcv9jop5ns2r.cn
抑郁气滞是什么症状hcv8jop2ns5r.cn 缎面是什么面料hcv7jop5ns3r.cn 牙齿黄是什么原因造成的hcv9jop1ns1r.cn 儿童身高矮小挂什么科yanzhenzixun.com 今年16岁属什么hcv8jop5ns0r.cn
肝功能2项是指什么hcv7jop9ns0r.cn 舌尖发麻是什么原因hcv8jop0ns4r.cn 健将是什么意思0297y7.com hpv疫苗是什么疫苗hcv7jop7ns0r.cn 眼睛胀痛是什么原因hcv9jop4ns9r.cn
荷花象征着什么hcv7jop9ns1r.cn 红枣泡水喝有什么好处hcv9jop1ns8r.cn 尿道疼是什么原因hcv9jop0ns8r.cn 前列腺炎吃什么hcv9jop8ns2r.cn 吃了虾不能吃什么bjhyzcsm.com
百度 技术支持:蜘蛛池 www.kelongchi.com