## Desktop

Frequent Visitor
Posts: 4
Registered: ‎08-09-2018

# Calculated Column - Return value if two columns matches

[ Edited ]

Hi!

I have a problem that seems simple but I just can't seem to solve it.

I'm trying to return Hours to a Calculated Column if Start Date and Date matches as in the example below:

I've tried both CALCULATE and IF but both returns errors:

`CALCULATE(SUM([Hours]);[Date] = [Start Date])IF([Start Date] = [Date];[Hours];"")`

Help would be much appreciated!

Marcus

Accepted Solutions
Super User
Posts: 671
Registered: ‎11-01-2017

## Re: Calculated Column - Return value if two columns matches

Hi

Can you try this ?

`New Column = IF(Table1[Start Date] = table1[Date],[Hours])`

Let me know if you see any issues.

Thanks

Raj

Established Member
Posts: 177
Registered: ‎04-27-2018

## Re: Calculated Column - Return value if two columns matches

@MarcusBI

I think the solution by @rajendran would work. You might be getting the error in your IF statement because you are setting the ELSE condition as "". This will probably cause an error because [Hours] is a number and "" is text. You can either use rajendran's version or you can switch the "" with BLANK()

Hope this helps,

Parker

All Replies
Super User
Posts: 671
Registered: ‎11-01-2017

## Re: Calculated Column - Return value if two columns matches

Hi

Can you try this ?

`New Column = IF(Table1[Start Date] = table1[Date],[Hours])`

Let me know if you see any issues.

Thanks

Raj

Frequent Visitor
Posts: 4
Registered: ‎08-09-2018

## Re: Calculated Column - Return value if two columns matches

Thanks for the reply but that is basically the same IF-formula that I have been trying and I receive an error.

Does this work for you?

Regards

Marcus

Established Member
Posts: 177
Registered: ‎04-27-2018

## Re: Calculated Column - Return value if two columns matches

@MarcusBI

I think the solution by @rajendran would work. You might be getting the error in your IF statement because you are setting the ELSE condition as "". This will probably cause an error because [Hours] is a number and "" is text. You can either use rajendran's version or you can switch the "" with BLANK()

Hope this helps,

Parker

Highlighted
Super User
Posts: 1,183
Registered: ‎12-29-2015

## Re: Calculated Column - Return value if two columns matches

@MarcusBIexactly what is the error you're getting? I have a feeling you're trying to add this as a measure and not a column...

Frequent Visitor
Posts: 4
Registered: ‎08-09-2018

## Re: Calculated Column - Return value if two columns matches

[ Edited ]

@rajendran did work leaving the last argument blank instead of "".

Thank you @Parker_Stevens for the clarification

Best regards,

Marcus