Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Making row value equal to Column Name

Hi, I can't figure out how to solve this dax problem of mine. I have searched the forum but could not find an answer. 

Given tables like this which are related one to Many (from left to right):
Table 1                                                            Table 2

Screenshot (5).png                  Screenshot (3).png

 

I know the right table only has the Name Value appearing only once per name but I created this simplistic example to help portray my problem.

 

What I want to do is to be able to add a Calculated Column that basically says that: if a value in column 'Code' is equal to the name of column '0191' or column '5191' or column '4221', then multiply Sales by the specific figure (from table 1) depending on Name and column name.

 

Screenshot (4).png

 

Is this possible?


Best Regards.

3 REPLIES 3
Anonymous
Not applicable

I would suggest restructuring your reference table like this:

NameCodeValue
John01912
Mark01915

And so forth. You can do this easily in the Power Query editor. (lookup how to pivot/unpivot tables)

Then you could write a formula like this:

 

Measure = 
VAR code = SELECTEDVALUE(Sales[code])
VAR name = SELECTEDVALUE(Sales[name])
RETURN
CALCULATE(
SUM(Table1[Value]),
Table1[code] = code && Table1[name] = name)
* Sales[Sales]

 

Anonymous
Not applicable

Thanks for the reply cstaulbee.

 

Unfortunately, the values in Table 1 from columns '0191', '5191', and '4221' are calculated columns. If I'm not mistake, I can only pivot tables from the original data source correct? If this is true, how should I go about solving this problem?

Anonymous
Not applicable

You could create calculated columns like the 2 that I gave as an example. I'm not sure what the data looks like that you're building the calculated columns off of so it's hard to say how you could do that.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.