Forum Discussion

SelflearningBi's avatar
SelflearningBi
Icon for Helper III rankHelper III
4 years ago

How to do percentage correctly.

Im using this dax function, I would like to also display the "NO" otif quanitty % correctly. Now only show the Yes % is correctly. Please help and thanks so much. 

 

2 Replies

  • Hi SelflearningBi ,

     

    In this case your issue is with the context of the calculation, since you are using the column OTIF has a context on the matrix visualization the CALCULATE function is making use of the ALL statement that way you are always getting the YES on your formula try to change the first part of the divide you will get the correct result try to replace your formula by:

    OTIF Quantity % =
    VAR sumofconfirmedqty =
        CALCULATE (
            SUM ( 'FW22 Order Database'[shipped Quantity(Total)] ),
            'FW22 Order Database'[OTIF] = "YES"
                || 'FW22 Order Database'[OTIF] = "NO"
        )
    RETURN
        DIVIDE (
            SUM ( 'FW22 Order Database'[shipped Quantity(Total)] ),
            sumofconfirmedqty
        )

     

    This should give expected result.

    • SelflearningBi's avatar
      SelflearningBi
      Icon for Helper III rankHelper III

       

      trial_OTIF Quantity % = 
      VAR sumofconfirmedqty = CALCULATE ( SUM ( 'FW22 Order Database'[shipped Quantity(Total)] ), 'FW22 Order Database'[OTIF] = "YES" || 'FW22 Order Database'[OTIF] = "NO" ) 
      RETURN DIVIDE ( CALCULATE('A-measure'[Sum Shipped Qty],'FW22 Order Database'[OTIF]="yes"), sumofconfirmedqty )​

       

      Hi, thanks for helping. I am using this formula but still only get the same result, and also I put the IN FULL column in the table. The table only displays YES. do you have any suggestution for that? 

      this is the new column I created 

       

      In Full = 
      SWITCH(TRUE(),
          ISBLANK('FW22 Order Database'[Shipped Qty Difference]),BLANK(),
      IF(AND('FW22 Order Database'[Shipped Qty Difference]>=0,'FW22 Order Database'[Shipped Qty Difference]<=0.02),"Yes","No"))

       

       MFelix