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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
AngelikaMcGill
New Member

Combining data from various columns into one column based on value in another column

Hopefully this isn't as complicated as it seems...

 

I am extracting data from Dynamics and in the extraction I have values that are coming into power bi in various columns instead of one based on the type of value (text, short text, integer, boolean, table, etc).  How would I create a DAX formula that looks at the type of the value "First Type" and returns the value in the column that it corresponds to.  So a value in "Text" in the First Type column would return the value from the "First AnswerText" column.  The report is really messy with 7 value columns instead of one.  Any help would be much appreciated.

powerbi questions.jpg

1 ACCEPTED SOLUTION
v-haibl-msft
Microsoft Employee
Microsoft Employee

@AngelikaMcGill

 

Does above solution help?

 

Best Regards,
Herbert

View solution in original post

5 REPLIES 5
v-haibl-msft
Microsoft Employee
Microsoft Employee

@AngelikaMcGill

 

Does above solution help?

 

Best Regards,
Herbert

I haven't had a chance to test it yet but it looks like it should work.  Thank you!

v-haibl-msft
Microsoft Employee
Microsoft Employee

@AngelikaMcGill

 

You can unpivot part of the columns as below in Query Editor.

 

Combining data from various columns into one column based on value in another column_1.jpg

 

Then create relationship between two tables using the First Type column.

 

Combining data from various columns into one column based on value in another column_2.jpg

 

I create a Tag column to indentify the answer using following DAX formula.

 

Tag = 
IF (
    Table1[First Type] = "ShortText",
    SEARCH ( "Text", Table1[Attribute],, -1 ),
    IF (
        Table1[First Type] = "Table",
        SEARCH ( "First GroupAnswer2", Table1[Attribute],, -1 ),
        IF (
            Table1[First Type] = "MultipleRadio"
                || Table1[First Type] = "MultipleCheckbox",
            SEARCH ( "First Checkbox", Table1[Attribute],, -1 ),
            SEARCH ( Table1[First Type], Table1[Attribute],, -1 )
        )
    )
)

Combining data from various columns into one column based on value in another column_3.jpg

 

At last, we only need to use the Tag column to get the desired answer.

 

Answer = 
CALCULATE ( MAX ( Table1[Value] ), Table1[Tag] > 0 )

Combining data from various columns into one column based on value in another column_4.jpg

 

Best Regards,
Herbert

 

Greg_Deckler
Community Champion
Community Champion

Can you post some sample data and example of the desired output that you want? Having trouble figuring out what you are trying to do here. You may have to pivot/unpivot those columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I'm just looking to line up the multiple columns into one as shown below:

 

powerbi questions sample.jpg

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.