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
bdehning
Post Prodigy
Post Prodigy

Custom Column Formula Help

I have the following formula for a custom column.  

 

It works except when Time Started or Time Injured is null and then my column returns an error

 

if([Time Started]>[Time Injured]) then [Time Injured]-[Time Started]+1 else [Time Injured]-[Time Started]

 

I would like to be to have the value be Unknown if possible?

1 ACCEPTED SOLUTION

@bdehning 

pls try this

if [Time Started] is null or [Time Injured] is null then null else if [Time Started]>[Time Injured] then [Time Injured]-[Time Started]+1 else [Time Injured]-[Time Started]

 

11.PNG





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

Proud to be a Super User!




View solution in original post

10 REPLIES 10
bdehning
Post Prodigy
Post Prodigy

 if([Time Started]>[Time Injured]) then [Time Injured]-[Time Started]+1 else [Time Injured]-[Time Started]  

 

How do I add "if  time injured is null or time started is null then null" to what I already have?

 

@bdehning 

pls try this

if [Time Started] is null or [Time Injured] is null then null else if [Time Started]>[Time Injured] then [Time Injured]-[Time Started]+1 else [Time Injured]-[Time Started]

 

11.PNG





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

Proud to be a Super User!




bdehning
Post Prodigy
Post Prodigy

bdehning_0-1704243572496.png

 Here is screen shot of Power Query   See my Time of Work Column which has the error?

@bdehning 

you can use  try...otherwise... to avoid error

Error handling - Power Query | Microsoft Learn

 





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

Proud to be a Super User!




Right,

 

So there is no easy add on to tell Custom Column it to produce "null" if one or both columns are null

 

The other way is 

if  time injured is null or time started is null then null 

i think "try" is easier.





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

Proud to be a Super User!




I do not need text until I create the Time to Injury Group Conditional Column  

bdehning
Post Prodigy
Post Prodigy

 I know that would be best but my report is so big and complicated, its hard to split out just the page and table I need for a sample.   

@bdehning 

not sure if this is what you want. We can't get text and number in one column

Column = if(ISBLANK('Table (2)'[Time Started]) || isblank('Table (2)'[Time Injured]),999,if('Table (2)'[Time Started]>'Table (2)'[Time Injured],'Table (2)'[Time Injured]-'Table (2)'[Time Started]+1,'Table (2)'[Time Injured]-'Table (2)'[Time Started]))

 

so i used 999 to replace the unknown

11.PNG





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

Proud to be a Super User!




ryan_mayu
Super User
Super User

@bdehning 

could you pls provide some sample data?





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

Proud to be a Super User!




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.