Forum Discussion

John_Peter's avatar
John_Peter
Regular Visitor
6 years ago
Solved

IF into formula

HI,

 

Hi,

I have this column in my table "Ventes" but the IF does not seem to work, it should give me 0 if Product = "CREDIT 601" or Livr_Pays = "US" but it still gives me __TauxDouanes

what is that i'm not doing correctly ????

Thank you very much for your support.

 

Gross$ =

VAR ProdCost = FILTER('Cost', 'Cost'[Attribute] = Ventes[Monnaie] && Ventes[d_date]>='Cost'[Valide_De] && Ventes[d_date]<=Cost[Valide_A])
VAR __Cost = CALCULATE(SUM(Cost[Value]),ProdCost)*Ventes[d_qty]
VAR __TauxDouane = CALCULATE(SUM(Cost[TAUX_DOUANE]),ProdCost)
RETURN
Ventes[Sales]-(__Cost+(Ventes[Sales]*IF(Ventes[Product]="CREDIT 601" || Ventes[Livr_Pays]="US",0,__TauxDouane))+(Ventes[Sales]*Ventes[Cust_Disc]))
 
 

 

  • Anonymous's avatar
    Anonymous
    6 years ago

    John_Peter 

    Did you check whether there are spaces in the values, sometimes there is a space before or after the text. 

    However, I don't see any problem with this DAX. Please provide a sample pibx file if this issue persist.

     

    Best regards

    Paul Zheng

     

2 Replies

  • az38's avatar
    az38
    Community Champion

    John_Peter 

    if you use create a measure, not column use SELECTEDVALE() over column name like

    IF(SELECTEDAVALUE(Ventes[Product])="CREDIT 601" || SELECTEDAVALUE(Ventes[Livr_Pays])="US", 0, __TauxDouane))

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    John_Peter 

    Did you check whether there are spaces in the values, sometimes there is a space before or after the text. 

    However, I don't see any problem with this DAX. Please provide a sample pibx file if this issue persist.

     

    Best regards

    Paul Zheng