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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
FoolzRailer
Helper I
Helper I

Create new table with columns based on different tables and conditions?

Hello

 

I'm trying to create a new table based on values in a different table. I have already created working relations between the tables. 

 

What I have tried to do in DAX is this, first create new table then new column: 

New Column= IF('Ledning'[Statuskode]=6;'Delledning'[OpstroemsNavn]&" - "&'Delledning'[NedstroemsNavn]&", "&"Ø"&'Delledning'[Handelsmaal]&", "&'K_LedningMateriale'[Ledningsmateriale_Beskrivelse])

Which if the condition was true I would like to a return af string looking like this without quotations: "155161S - 155131S, Ø200, PVC"

 

But I keep getting a error A single value for column 'Statuskode' in table 'Ledning' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @FoolzRailer 

The judgment basis in your if statement must come from the same table, so you cannot use 'Ledning'[Statuskode]=6 as the condition. You need to create a corresponding calculated column in the Delledning table as the condition.

Take a try formula as below:

Calculated column in Table"Delledbing":

Statuskode =related('Ledning'[Statuskode])

Measure:

New Column= IF('Delledning'[Statuskode]=6,'Delledning'[OpstroemsNavn]&" - "&'Delledning'[NedstroemsNavn]&", "&"Ø"&'Delledning'[Handelsmaal]&", "&'K_LedningMateriale'[Ledningsmateriale_Beskrivelse])

 

If it doens't meet your requirement,please  how the table structure and  the relationship between current two tables. It will be better if you can share a sample pbix file for tesing.

Best Regards,
Community Support Team _ Eason

 

 

 

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community Support

Hi, @FoolzRailer 

The judgment basis in your if statement must come from the same table, so you cannot use 'Ledning'[Statuskode]=6 as the condition. You need to create a corresponding calculated column in the Delledning table as the condition.

Take a try formula as below:

Calculated column in Table"Delledbing":

Statuskode =related('Ledning'[Statuskode])

Measure:

New Column= IF('Delledning'[Statuskode]=6,'Delledning'[OpstroemsNavn]&" - "&'Delledning'[NedstroemsNavn]&", "&"Ø"&'Delledning'[Handelsmaal]&", "&'K_LedningMateriale'[Ledningsmateriale_Beskrivelse])

 

If it doens't meet your requirement,please  how the table structure and  the relationship between current two tables. It will be better if you can share a sample pbix file for tesing.

Best Regards,
Community Support Team _ Eason

 

 

 

mahoneypat
Microsoft Employee
Microsoft Employee

Not sure which table you are creating that column on, but ou are referencing two tables in that expression.  While you have a relationship, more is needed to know which row in the other table is needed.  You will need to use RELATED or RELATEDTABLE in your expression, or something like CALCULATE(MIN(Table2[ColumnName]) to trigger context transtion (to turn the context of the row you are on to a filter on the related table).

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


I'm trying to add my new calculated IF column in a new empty table i just made. So basically I have a completly empty table, where I would like to add some data from Dellednings table but only if the StatusKode in Ledningstable is 6. 

Not quite sure how to work with related as I'm fairly new to this, and I don't have any data in my new table I'm trying to create. I'm sorry if this is a bad approach, I'm kinda learning by doing. I've added a picture with some sample data. 

 

PowerBI .png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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