Skip to main content

Power BI

New

DAX Measure referencing DAX expressions stored in a table to define common calculations

Vote (1) Share
Gustav G Franck's profile image

Gustav G Franck on 11 Jun 2024 08:08:17

The idea is to implement a DAX function that converts a string containing a DAX expression into the expression itself within a DAX Measure. These strings would be stored in tables to collect commonly used expressions for various business specific calculations / aggregations. An example being Calendar aggregations such as Week To Date, Previous Week, Same Period Last Year. Currently creating such predefined calculations required mass producing measures, creating one for each and often doing it for each calculation measure.

Allowing DAX to reference calculations stored as a string in a table would allow Power BI developers to create a table of these commonly used expressions and simply look them up in the table and add functionality such as Slicers to allow users to switch between aggregation types easily. This is to an extent inspired by the Excel function Indirect, which allows you to dynamically alter calculations based on the contents of a cell.