Conditional Code Branching in Power BI Query: if…then…else => then…else…if

If…Then…Else in a Custom Column

We have all used an “if…then…else” statement, when adding a custom column in Power BI query (using Excel Power Query, or Power BI > Get Data). Here is a quick example from our book, Chapter 20 “Power Query to the Rescue”, Scenario #3 – Adding Custom Columns to Your Lookup Tables.

Power_Query_Add_Custom_Column
Adding a custom column using if…then…else

If…Then…Else for Conditional Code Branching

However in my previous life, I was used to using if…then…else for conditional code branching when using programming languages (VBA counts, right?). Based on the if condition, code execution follows two completely separate paths.


Conditional Code Branching, lets you follow separate execution paths based on condition

This is easily done in most programming languages, but initially I could not quite figure this out for a Power BI query. One thing that kept tripping me up was to think of M as a Functional Language.
Continue reading

Flat to Star Transformation using DAX Query

By Avi Singh [Twitter]
As I have started working with clients around training/consulting, I am surprised by how often I find tables FlatToStar_RockyIV that have been flattened, i.e. the data tables have been combined (joined) with lookup tables, to produce a really wide table with everything and the kitchen sink in it. Maybe that’s to be expected; after all that is the modus operandi when working in Excel. That’s the first habit that I try to break…
Continue reading at PowerPivotPro…