cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
twolten Frequent Visitor
Frequent Visitor

Concatenating results from an IF statement

Hi all,

 

I am trying to have a multiple IF Statement where it looks for a value and then if it matches it adds the result but if it only matches the third or fourth IF Statement then it adds those values instead.

 

Example:

=IF(Col1 || Col2 >0, "Ans1", IF(Col3 || Col4>0, "Ans2", IF(Col5 || Col6>0, "Ans3", "Ans4))))

 

Desired Outcome:

Row1 where Col1 = 1 and Col5=2 result would equal "Ans1Ans3"

 

Row2 where Col1=0 and Col6=6 result would equal "Ans3"

 

Row3 where all Col=0 result would equal "Ans4"

 

All thoughts and help would be gretaly appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Concatenating results from an IF statement

Hi @twolten,

 

Nope. dax not support calculation which you mentioned, you had to manually write formula/variable to calculate and return merged result .

 

Calculate column formula:

 

formula =
VAR v1 =
    IF ( Table[Col1] + Table[Col2] > 0, "Ans1" )
VAR v2 =
    IF ( Table[Col3] + Table[Col4] > 0, "Ans2" )
VAR v3 =
    IF ( Table[Col5] + Table[Col6] > 0, "Ans3" )
VAR v4 =
    IF (
        Table[Col1] + Table[Col2]  + Table[Col3] + Table[Col4] + Table[Col5] + Table[Col6] = 0,
        "Ans4"
    )
RETURN
    IF ( v4 <> BLANK (), v4, v1 & v2 & v3 )

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Concatenating results from an IF statement

Hi @twolten,

 

Nope. dax not support calculation which you mentioned, you had to manually write formula/variable to calculate and return merged result .

 

Calculate column formula:

 

formula =
VAR v1 =
    IF ( Table[Col1] + Table[Col2] > 0, "Ans1" )
VAR v2 =
    IF ( Table[Col3] + Table[Col4] > 0, "Ans2" )
VAR v3 =
    IF ( Table[Col5] + Table[Col6] > 0, "Ans3" )
VAR v4 =
    IF (
        Table[Col1] + Table[Col2]  + Table[Col3] + Table[Col4] + Table[Col5] + Table[Col6] = 0,
        "Ans4"
    )
RETURN
    IF ( v4 <> BLANK (), v4, v1 & v2 & v3 )

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |

View solution in original post

twolten Frequent Visitor
Frequent Visitor

Re: Concatenating results from an IF statement

Thank you for this, it is really helpful!

 

However, I have run into another problem now. With the DAX calaculation complete I realised there is no way to parse the results of the calculation for filtering purposes.

 

For instance on result will have 'Ans1,Ans4' and another will have 'Ans1,Ans2,Ans3'

 

How can I parse these to be able to filter the results? Any ideas?

 

Thank you again for the help so far.

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 59 members 1,073 guests
Please welcome our newest community members: