8. Adding Columns: Power Query Add Column Tab and DAX Calculated Columns
8.2 Column From Examples
Start with a problem
Ruhi needs a First Name column but doesn't remember Text.BeforeDelimiter.
Explain simply
Column From Examples: type the result you want for one or two rows; Power Query writes the formula. Check the formula it shows.
Show the data
| Full Name |
|---|
| Ravindra Bagale |
| Shraddha Bagale |
| Ruhi Bagale |
| Salman |
About this data: This table uses columns: Full Name, First Name. This table uses columns: Input, You type, Power Query suggests. This table uses columns: Wrong result, Reason, Correction. Values shown are the lesson examples already on this page (not a new dataset).
Fictional sample data. Practice file: pq_customers_text.csv (source: src/practice/).
Demonstrate
- Select Full Name › Add Column › Column From Examples › From Selection.
-
Type
Ravindrain the first row › Enter.Your result should look like this:
Suggested values Ravindra, Shraddha, Ruhi, Salman -
Read the formula at the top, e.g.
Text.BeforeDelimiter([Full Name], " "); click OK.
Show the result
Your result should look like this (fictional sample):
| Full Name | First Name |
|---|---|
| Ravindra Bagale | Ravindra |
| Shraddha Bagale | Shraddha |
| Ruhi Bagale | Ruhi |
| Salman | Salman |
Explain what happened
Power Query found a rule that produces your example and applied it to all rows. Always check edge rows such as the single-word name Salman.
Explore further
- Works for dates too: type
Aprilnext to 06-Apr-2026 → Date.MonthName.
Detailed reference for this lesson:
You type the answer, and Power Query works out the formula.
Steps in Power BI
- Select the column(s) to use, for example Customer Name (values like "Shraddha Bagale").
- Add Column › Column From Examples › From Selection (or From All Columns).
- In the new empty column type
Shraddhain the first row and press Enter. Power Query fills the other rows and shows the formula at the top (Text Before Delimiter " "). - If a row is wrong, type the correct value in that row too. Two or three examples are usually enough.
- Rename the column (double-click the header in the dialog) to First Name › OK.
| Input | You type | Power Query suggests |
|---|---|---|
| Blinkit Kothrud (Pune) | Kothrud | Text Between Delimiters " " and " (" |
| 2025-10-20 21:47 | Oct-2025 | Date.ToText with format "MMM-yyyy" |
| 480 | 400-499 | A range (bucketing) formula |
Ravindra Bagale's Tip
Remember one thing: accepting the first Column From Examples suggestion without reading the formula is risky. It may work for the preview rows but fail for others (for example names without a space). Type two or three examples, then read the formula shown at the top before clicking OK. This matters for both exams and interviews.
Ravindra Bagale's Tip – मराठी
एक गोष्ट लक्षात ठेवा: formula न वाचता Column From Examples ची पहिली suggestion स्वीकारणं धोकादायक आहे. ती preview rows साठी चालेल पण इतर rows साठी fail होऊ शकते (उदाहरणार्थ space नसलेली नावं). दोन-तीन examples type करा, मग OK करण्याआधी वरती दिसणारा formula वाचा. हे exam आणि interview दोन्हीसाठी important आहे.
Ravindra Bagale's Tip – हिंदी
एक बात याद रखो: formula पढ़े बिना Column From Examples का पहला suggestion मान लेना जोखिम भरा है. वह preview rows पर चल सकता है पर दूसरी rows पर fail हो सकता है (जैसे बिना space वाले नाम). दो-तीन examples type करो, फिर OK करने से पहले ऊपर दिखाया गया formula पढ़ो. यह exam और interview दोनों के लिए ज़रूरी है.
Practice task
From Store ID "BLK-PUN-KOT-01", use Column From Examples to get the City Code "PUN".
Fix common mistakes
| Wrong result | Reason | Correction |
|---|---|---|
| Wrong rule guessed | One example was ambiguous | Type a second example |
| Salman shows blank or error | The guessed rule expects a space in every row | Check single-word rows; type a second example (Salman) |
| Can't edit later | Thought it was magic | Edit the generated M in the formula bar |
Practise independently
Practice task
Use Column From Examples on Area City to get only the City (type Pune for row 1).
Hints
- Text after -.
Solution
Pune, Nashik, Kolhapur, Nashik – formula Text.AfterDelimiter([Area City], "-").
Think like a professional
Always read the generated formula – you learn M and avoid hidden wrong rules.
Revision card