Skip to main content

Power BI

Needs Votes

DAX: Allow Measures to return objects (eg: filtered tables)

Vote (2) Share
Niklas M's profile image

Niklas M on 09 Jul 2019 03:44:48

Many times I end up writing calculated dax code with nested ifs etc just to determine exactly what tables i should filter and exactly how. It annoys me like crazy to have to re-write that same code in another measure that needs the same logic. I would like like to move this code into a separate DAX measure, and then just say:
myFilteredTable = [MyFilteredTable]

where the [MyFilteredTable] actually returns a table "object".

This would be very benificial because:
# I could re-use DAX code, and avoid having to rewrite the same conditional logic in each new measure that needs that same logic
# I would just have to change the code in ONE place, if I discover I need to change the logic
# Since measures are evaluated inside the filter context of whatever DAX code they are placed into, the results can be very dynamic and give very creative opportunities

I feel very unprofessional repeating my code all over the place and quite frankly feel like its beneath the level of a pro tool like Power BI to not solve this more elegantly.

Please have a look at this!