13.5Text functions

A code to cut up, a name to put in capitals, your texts often need a helping hand. These functions work on text, like their Excel counterparts. The examples start from the product code A101.

13.5.1LEFT, RIGHT and MID

In Excel
DAXLEFTRIGHTMID
ExcelLEFTRIGHTMID
Match

The product code hides the brand. Its second character is 1 for Velmo and 2 for Kordan. If your extract gave you only the code, you would find the brand by taking this character.

LEFT, RIGHT and MID take part of a text, at the start, at the end or in the middle.

The syntax of LEFT, RIGHT and MID
The startLEFT( <text>, [<number of characters>] )
The endRIGHT( <text>, [<number of characters>] )
The middleMID( <text>, <start position>, <number of characters> )

All three first expect the text, often a column. LEFT and RIGHT then expect the number of characters to keep. If it is left out, they keep just one. MID expects the start position, then the number of characters.

On row A101:

  • LEFT( Products[Product Code], 1 ) returns A.
  • RIGHT( Products[Product Code], 3 ) returns 101.
  • MID( Products[Product Code], 2, 1 ) returns 1.

MID starts at the 2nd character and takes one.

This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.

Tip

RIGHT returns the text “101,” not the number 101. VALUE( RIGHT( Products[Product Code], 3 ) ) turns it into a number.

Practice

Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.

  1. Direct useCalculated columnDifficulty

    In a library, the call number of each book starts with the three letters of its section. Add to the “Books” table the calculated column “Section,” which keeps the first three characters of the call number.

    Books
    TitleCall Number
    DuneROM-0451
    Roman EmpireHIS-0112
    The CosmosSCI-0890

    Which formula should you write for “Section”?

  2. Combined useCalculated columnDifficulty

    The library wants to spot its novels, filed in the “ROM” section. Add to the “Books” table the calculated column “Novel,” which shows “Yes” or “No.”

    Books
    TitleCall Number
    DuneROM-0451
    Roman EmpireHIS-0112
    The CosmosSCI-0890
  3. Direct useCalculated columnDifficulty

    A hotel gives each booking a code that ends with a 4-digit number. Add to the “Bookings” table the calculated column “Number,” which keeps the last four characters of the code.

    Bookings
    GuestCode
    DurandR2026-0147
    MartinR2026-0152
  4. Combined useCalculated columnDifficulty

    The hotel wants to sort the bookings by number, as numbers. The number is made of the last four characters of the code. Add to the “Bookings” table the calculated column “Number,” as a number.

    Bookings
    GuestCode
    DurandR2026-0147
    MartinR2026-0152
  5. Direct useCalculated columnDifficulty

    A sports club gives each member a number whose 5th character shows the category, “J” for junior, “A” for adult, “S” for senior. Add to the “Members” table the calculated column “Category,” which keeps this single character.

    Members
    NameNumber
    Inès2026J0458
    Hugo2025A0112
    Jade2026S0031
  6. Combined useCalculated columnDifficulty

    The club offers a reduced rate to juniors. In each member’s number, the 5th character shows the category, “J” for junior. Add to the “Members” table the calculated column “Rate,” which shows “Reduced” or “Full.”

    Members
    NameNumber
    Inès2026J0458
    Hugo2025A0112
    Jade2026S0031

The rest of this lesson is part of izyDAX Pro

You have just read the first section. The next 3, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.