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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated Column - Return value if two columns matches

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:

 

Skärmklipp.PNG

 

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

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi

 

Can you try this ?

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

Let me know if you see any issues.

 

 

Thanks

Raj

View solution in original post

Anonymous
Not applicable

@Anonymous

 

I think the solution by @Anonymous 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

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi

 

Can you try this ?

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

Let me know if you see any issues.

 

 

Thanks

Raj

Anonymous
Not applicable

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

Anonymous
Not applicable

@Anonymous

 

I think the solution by @Anonymous 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

Anonymous
Not applicable

 

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

Thank you @Anonymous for the clarification 🙂

 

Best regards,

Marcus

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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