Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hey Guys,

Thanks for having me :) I'm a beginner please take it easy haha!

Basically I have a calculation field, where I am trying to force the answer as "0" when the calc returns "?" (due to an empty field etc, for whatever reason I'm not concerned about)

My calc is:

Round ( If ( IsEmpty ( Cash Sales Total Sales Value )=1 ; 0; (Cash Sales Total Last 7 Days-(Landed Cost*Cash Sales Total Last 7 Days)*1.2) / Cash Sales Total Sales Value ); 2)

Now it returns an answer when there is one, or a "?" when insufficient data, all I want is to return a "0" in this case rather than a "?"

 

Thanks in advance and sorry for the noob question

Edited by hutchlad
tags

Maybe this?

if(Round ( If ( IsEmpty ( Cash Sales Total Sales Value )=1 ; 0; (Cash Sales Total Last 7 Days-(Landed Cost*Cash Sales Total Last 7 Days)*1.2) / Cash Sales Total Sales Value ); 2) = "?";

0

;Round ( If ( IsEmpty ( Cash Sales Total Sales Value )=1 ; 0; (Cash Sales Total Last 7 Days-(Landed Cost*Cash Sales Total Last 7 Days)*1.2) / Cash Sales Total Sales Value ); 2))

more professional method is using Let function:

Let(

Calculation = Round ( If ( IsEmpty ( Cash Sales Total Sales Value )=1 ; 0; (Cash Sales Total Last 7 Days-(Landed Cost*Cash Sales Total Last 7 Days)*1.2) / Cash Sales Total Sales Value ); 2);

if(Calculation = "?";0;Calculation)

)

 

  • Author

Hi Siroos,

Brilliant! Thanks so much for helping me out, I really like the look of the Let function you wrote, however when use the calc, it does change the ? to 0 but also the true figures are different values than originally :blink:

My pleasure, is your calculation filed set to return numbers or text?

3 hours ago, hutchlad said:

Basically I have a calculation field, where I am trying to force the answer as "0" when the calc returns "?" (

It would be helpful to see the original calculation, before you tried to "force" it. What you gave us is difficult to read, esp. when we don't know what the calculation's purpose is. I think you want do:

If ( 
Cash Sales Total Sales Value ; 
Round ( ( Cash Sales Total Last 7 Days - Landed Cost * Cash Sales Total Last 7 Days * 1.2 ) / Cash Sales Total Sales Value ; 2 ) ;
0
)

This tests that your divisor is not empty or zero and if so, performs the division and rounds the result. Otherwise it returns 0. Note that 0 does not require rounding.

--
P.S. IMHO, outputting an artificial zero result is bad practice. The correct result in case of division by zero should be either an error or nothing.
 

Create an account or sign in to comment

Similar Content

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.