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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
MKPartner
Helper I
Helper I

[Expression.Error] cannot convert null value to Logical

Hi Guys, 

 

I have two columns where both are without "null" values: 

PV_orig = ([orig_tot_fabric_assgn_qty]*[prod_cost])/4.84)

and

(([g1_metres]+[g0_metres]+[g2_metres]+[dk_metres]+[allow_metres]+[qc_metres])*[prod_cost])/4.84)

 

Based on two above columne I want to pick higher value using below: 

PV LE = if [PV_real] >= [PV_orig]
then [PV_real]
else [PV_orig]

 

Final result is error during Power Bi refreshing like in header. I don't understand why even there is no null value to compare and if I pick PV LE column like PV_real or PV_orig seperately then everything is works. I gues, if function is givong a problem but I don't know why.

 

Thanks for help. 

3 REPLIES 3
NumaData
Helper I
Helper I

Hi there, 

Perhaps you could wrap your DAX with another if statement to protect against nulls like this:

PV_LE = if (if [PV_real] = null then 0 else [PV_real])
>= (if [PV_orig] = null then 0 else [PV_orig])
then [PV_real]
else [PV_orig]

You could also find the max pretty neatly in Power Query using this M Code as a new Column: 
PV_LE = List.Max({ [PV_real], [PV_orig] }) - Returns the maximum item in the list or the optional default value if the list is empty

Let me know if this helps!
Numa


KarinSzilagyi
Resolver III
Resolver III

Hi @MKPartner just to be 100% sure: Did you check e.g. via "View > Column profile" or "View > Column Quality" in Power Query Editor that there definitely aren't any null-values in any of the columns used in a mulitplication for your added columns?

KarinSzilagyi_0-1760087948724.png

KarinSzilagyi_1-1760088165698.png


Don't forget to switch to "Column profiling based on entire data set" if your table has >1000 rows:

KarinSzilagyi_2-1760088239293.png

 

raisurrahman
Frequent Visitor

@MKPartner 

I’m fairly certain there are nulls. As @KarinSzilagyi suggested, please check Column quality and Column profile. By default, Power Query infers data types from only the first 1,000 rows. If possible, load the data into an Excel table and review the entire dataset.

Regards,
Rais

Helpful resources

Announcements
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.

Users online (207)