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
Yaniv
Helper I
Helper I

Insert blank value based on another field

Hi,

 

I have a table named 'service'.

I want to create a new calucuated column that says if the field 'done' (date field) is blank do not insert any value but if the 'done' field is not blank insert the date value+one day.

Below what I already tried - 

 

1. NewColumn= IF(Service[Done]=BLANK(),BLANK(),Service[Done]+1) 

I get the error message - Column '' in Table '' contains blank values and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table.

 

2. NewColumn = IF(Service[Done]=BLANK()," ",Service[Done]+1)

Error message: Expressions that yield variant data-type cannot be used to define calculated columns.

 

Does anyone have an idea how to resolve it? I'm getting frustrated Smiley Happy

 

1 ACCEPTED SOLUTION

Hi @Yaniv,

 

I changed the data type of Service[Done] from Text to Date/Time, delete and recreate the calculated column Service[DoneDate], everything worked.

 

I have sent you the modified pbix file through private message.

 

Best regards,
Yuliana Gu

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

View solution in original post

17 REPLIES 17
v-yulgu-msft
Employee
Employee

Hi @Yaniv,

 

For this formula:  NewColumn = IF(Service[Done]=BLANK()," ",Service[Done]+1)

As " " is a string value, while Service[Done]+1 returns date value, two different data types cannot exist in a single column. Otherwise, variant data-type error will prompt.

 

For this formula: NewColumn= IF(Service[Done]=BLANK(),BLANK(),Service[Done]+1)

It works fine and returns expected date in my test. I didn't the same error. So, in your scenario, were you creating calculated column in service table? How many tables and columns are referred to in your formula? Please provide more information so that I can reproduce your problem.

 

Best regards,
Yuliana Gu

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

Hi @v-yulgu-msft

 were you creating calculated column in service table? - Yes, the calcuated column is in the same table (service).

How many tables and columns are referred to in your formula? - Only 1 table and one column.

 

Thanks!!

Hi @Yaniv,

 

I cannot reproduce your problem. Please share some sample data so that I can test for you. Or, if possible, share your pbix file.

 

Regards,
Yuliana Gu

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

I hope the attached screenshot will make it clear.11.jpg

Hi @Yaniv,

 

I noticed that in formula, the source column is Service[Done], but in data view, you pointed out that source column is [Created], why? Also, from the error message, what is the "in Table" column? Did you created any relationship between this table and another table?

 

Regards,
Yuliana Gu

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

HI @v-yulgu-msft,

 

Yes, there is a mistake in the screenshot. The column source is done and not 'created' but they are same data type (date). I haven't created any relationship for this table.

Appreciate your assistance. 

 

Hi @Yaniv,

 

Could you please share your pbix file?

 

Regards,
Yuliana Gu

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

@v-yulgu-msft,How can I shre it with you? I haven't find an option to attach file to a message here.

Am I missing something? 

Hi @Yaniv,

 

Can you see this option when posting a reply?

4.PNG

Regards,
Yuliana Gu

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

@v-yulgu-msft - Unfortunately, I can't. I just have the option ot attach an image file. 

Please see the screenshot below.

powerbi form.jpg

Hi @Yaniv,

 

As suggested in above link, could you please upload and share the sample files on OneDrive, Dropbox etc?

 

Regards,
Yuliana Gu

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

 

Hi @v-yulgu-msft,

 

I sent you a private message.

 

Hi @Yaniv,

 

I changed the data type of Service[Done] from Text to Date/Time, delete and recreate the calculated column Service[DoneDate], everything worked.

 

I have sent you the modified pbix file through private message.

 

Best regards,
Yuliana Gu

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

Hi @v-yulgu-msft,

 

I also tried to do that but the option of changing to date format was grayed out.

Can you please advise me how did you do that?

Hi @Yaniv,

 

Was my suggestion helpful to you? If yes, would you please kindly mark the corresponding reply as an answer?

 

Best regards,
Yuliana Gu

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

HI @v-yulgu-msft,

 

Yes, there is a mistake in the screenshot. The column source is done and not 'created' but they are same data type (date). I haven't created any relationship for this table.

Appreciate your assistance. 

 

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.