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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Employee
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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.