Skip to main content

Power BI

Needs Votes

Create DAX programmatically in PowerQuery then execute in PowerBI as a measure

Vote (6) Share
Dan Thompson's profile image

Dan Thompson on 02 Jul 2018 23:51:02

I would like the option to be able to build a PowerBI model using some external DAX code, perhaps importing formulas created in Excel into the PowerBI model to create Measure tables where there are a lot of similar measures, that could be created from an Excel / PowerBI formula. The only problem is that you can't then execute the DAX as it's stored in a column in the PowerBI model, not in a DAX measure. I would like to be able to take the DAX I crafted and create a measure automatically using the PowerQuery Editor. i.e. pass the text from the PowerQuery into a Measure. I'm thinking a simple table in PowerQuery where the columns are Measure Name and DAX Expression, or even just Measures where the column includes the name e.g. {MeasureName}={DAX Expression}. I think there is a similar feature in other tools such as Qlik. This would help to reduce time to create measures as you could create in Excel/PowerQuery with formulas rather than copy / paste and modify.