Forum Discussion

pmadam's avatar
pmadam
Helper II
5 years ago
Solved

Help division error

Hi All,

 

I am trying to divide two text columns for a particluar dimension. So i get error when the numerator or denominator has blank value. I went forward and added if clause as below but i still get below error . 

 

Kindly sugest 

 

XY =
IF(ISBLANK([DSAM Amount]) && Not ISBLANK(VALUE([Customer Target])) <> "", 0 ,
(
([Customer Target] /
[DSAM Amount])))
 
 

 

 

  • pmadam Maybe:

    XY =
    IF(
      ISBLANK([DSAM Amount]) && Not(ISBLANK(VALUE([Customer Target]))), 
      0 ,
      [Customer Target] / [DSAM Amount]
    )

8 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    pmadam Use the DIVIDE function like this (get rid of the IF clause)

     

    XY =DIVIDE([Customer Target],[DSAM Amount],0)
     
    Third parameter is the one to return in case of divide by zero.
  • Anonymous's avatar
    Anonymous
    Not applicable
    The error says it all: you cannot compare bool values with text. Makes no sense... Here's how to use IF: IF( <logical_condition>, <case_for_True>, <case_for_False> ). You cannot do this True <> "". This comparison is not defined.
  • Hi Greg_Deckler ,

     

    I get error. These measures are in text because when i added comma seperator, the measures were converted to type int to text.

     

    • dedelman_clng's avatar
      dedelman_clng
      Community Champion

      pmadam you have the wrong syntax for DIVIDE:

       

      Greg_Deckler 's code:  XY =DIVIDE( [Customer Target], [DSAM Amount], 0 )

       

      Your code: XY =DIVIDE( [Customer Target] / [DSAM Amount] ,0 ). 

       

      Even if you didn't throw an error with one of your "numbers" being empty, you are dividing by 0.

       

      Hope this helps

      David

    • Anonymous's avatar
      Anonymous
      Not applicable
      pmadam

      Why are you outputting numbers as text? This is not how you do stuff correctly. If you want to format a number in a visual, please use the formatting options in the ribbon, not the FORMAT function.
    • Pragati11's avatar
      Pragati11
      Super User

      Hi pmadam ,

       

      Are bot of your columns numeric which you are trying to divide.

      DIVIDE is function that works on non-text values. If you think logically, how can you divide a text value by a numeric value.

       

      Try modifying data type of your text column used in DIVIDE function to Numeric.

       

      Thanks,

      Pragati