Forum Discussion
Visual Calculation_If blank, 0 and NaN
Hi can anyone help me on my visual calcualtion result,
if the result is blank will be equal to 0
if the result is NaN will be equal to 0
Thank you
Hi,
I am not sure how your semantic model looks like, but please try something like below.
Please check the below picture and the attached pbix file.
Hi AllanBerces
ideal way of handling NaN will be in DiIVIDE DAX function or PowerQuery.
add below powerquery step to convert NaN to null
#"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [#"%Actual_rev"]<> null and Number.IsNaN([#"%Actual_rev"]) then null else [#"%Actual_rev"]) // replace [#"%Actual_rev"] with column which has NaNafter handling the NaN, you can try below Visual Calculation.
[%Actual_rev] = format(SWITCH(TRUE(), ISBLANK( [Earned]/[Total Hrs]),0 , [Earned]/[Total Hrs] ),"0")Please give Kudos or mark it as solution once confirmed.
Thanks and regards,
praful
4 Replies
- Jihwan_Kim
Super User
Hi,
I am not sure how your semantic model looks like, but please try something like below.
Please check the below picture and the attached pbix file.
- AllanBerces
Post Prodigy
Hi Jihwan_Kim Praful_Potphode thank you very much working as i need
- Rufyda
Super User
I'm glad you found a solution! We're here in the community to support each other. 🤝
- Praful_Potphode
Super User
Hi AllanBerces
ideal way of handling NaN will be in DiIVIDE DAX function or PowerQuery.
add below powerquery step to convert NaN to null
#"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "Custom", each if [#"%Actual_rev"]<> null and Number.IsNaN([#"%Actual_rev"]) then null else [#"%Actual_rev"]) // replace [#"%Actual_rev"] with column which has NaNafter handling the NaN, you can try below Visual Calculation.
[%Actual_rev] = format(SWITCH(TRUE(), ISBLANK( [Earned]/[Total Hrs]),0 , [Earned]/[Total Hrs] ),"0")Please give Kudos or mark it as solution once confirmed.
Thanks and regards,
praful