Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello! I need to use measure that returns the column name from one take using selectedvalue, and use this columnname to get the column. Example:
Here is my first table:
id | attribute |
1 | Purchase |
1 | Emotion |
1 | Likability |
2 | Purchase |
2 | Likability |
2 | Emotion |
I will use attribute column as a filter, those 3 attributes are the column names of my second table:
id | Purchase | Likability | Emotion | ||
1 | 0.342 | 0.835 | 0.756 | ||
2 | 0.432 | 0.657 | 0.235 | ||
3 | 0.754 | 0.654 | 0.765 |
I need to create a formula, to calculated the average of one specific column based on attribute column from the first table:
so I now use:
var filter_attribute = selectedvalue('1 table'[attribute])
var mean = calculate(average( '2 table'[*filter_attribute*] ))
What do I need to put filter_attribute(column name) to DAX will consider it as the column named like this? Thanks in advance!
Solved! Go to Solution.
@Anonymous I would highly recommend that you unpivot those three columns in your 2nd table and then this problem becomes trivial. Alternatively you would have to do this:
var filter_attribute = selectedvalue('1 table'[attribute])
var mean =
SWITCH(__filter_attribute,
"Purchase",calculate(average( '2 table'[Purchase] )),
"Likeability",calculate(average( '2 table'[Likeability] )),
"Emotion",calculate(average( '2 table'[Emotion] )),
)
@Anonymous I would highly recommend that you unpivot those three columns in your 2nd table and then this problem becomes trivial. Alternatively you would have to do this:
var filter_attribute = selectedvalue('1 table'[attribute])
var mean =
SWITCH(__filter_attribute,
"Purchase",calculate(average( '2 table'[Purchase] )),
"Likeability",calculate(average( '2 table'[Likeability] )),
"Emotion",calculate(average( '2 table'[Emotion] )),
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |