#4 Lesson | Learn to Code with Microsoft M-Language: Working with Structured Values

SPRDsheet
4 min readMar 29, 2018

--

In the previous lesson, you learned about primitive values. We briefly touched on structured values as well. Let’s take a closer look at them now. Given that there are 15 different kinds of values, make sure you read the Microsoft M-Language Specification, as I will only provide a brief introduction here in order to grow your appetite to learn more.

In this chapter, I will mainly focus on three kinds of structured values:

  • lists
  • records
  • tables

As you learned in the previous chapter, M-Language buckets values into two categories:

  1. primitive values such as numbers: 1, 2, 3, 4, 5
  2. structured values which can consist of primitive values: 1 + 2 for example

Let’s go ahead and create a list of greetings in different languages. Open up the Advanced Editor and type out the following code.

let
Source = {"France", "Germany", "Spain"}
in
Source

Hit Done. You just created a sweet, little list of countries. In the Properties > Name field change the default name Query1 to something more meaningful, for example: CountryList. Hit enter, otherwise the name is not going to change.

Let’s go ahead and create a record. Select New Source > Other Sources > Blank Query. Next click on the Advanced Editor icon and type out (or copy and paste) the following code.

let
Source = [Francois Labelle = "Je suis très content de votre service :-)", Hans Dampf = "Euer Service ist GROTTENSCHLECHT!!!", Carlos González = "Puedo recomendar su servicio"]
in
Source

Hit Done, and next, under Properties > Name change the default name Query1 to SupportCallRecord. You should see this.

Now, let’s crate a table. On the Home Tab, select New Source > Other Sources > Blank Query. Click on the Advanced Editor and type out this code (or just copy and paste it if you like).

let
Source = #table({"Customer Feedback", "English Translation"},{{"Je suis très content de votre service :-)", "I am very happy with your service :-)"},{"Euer Service ist GROTTENSCHLECHT!!!", "Your sercice SUCKS!!!"},{"Puedo recomendar su servicio", "I can recommend your service"}})
in
Source

Hit Done, change the name from Query1 to TranslationTable and hit enter. That’s what you should see now.

What have we just done? We crated a list, a record and a table. Not only that. We made up a scenario that is very common in the corporate world. Imagine for a minute, you want to measure customer satisfaction across your company’s global support organization and you get a truckload of messy data:

  • a list with countries your company caters to
  • the actual records from customer support calls
  • a table with translations of the customers’ feedback

How would you consolidate that data into one readable, meaningful table? That’s where M-Language shines! In the next chapter, we will do exactly that.

Before we do that, let’s save the queries we just created. On the Home Ribbon, click on the lower part of the Close & Load icon. From there, you will be prompted to select from two options:

  • Close & Load
  • Close & Load to …

Please pick Close & Load to …

An Import Data window will pop up. Select Only Create Connection and hit OK.

Next, select the File Tab and save this Workbook on your computer as SupportData.

Lean back for a minute, and let’s move on to the next lesson!

This is my entire course

--

--

SPRDsheet

All things spreadsheet. Microsoft Excel and beyond. SPRDsheet is about sharing learnings amongst peers, regular folks who love to learn & work.