Forum Discussion

Pfandgiraffe's avatar
Pfandgiraffe
Frequent Visitor
3 years ago
Solved

IF combined with a CALCULATE function

Hey,   i want to combine a IF-question with a CALCULATE function. First i want to compare two values. Depend on the result i want to use the one or the other formular with the calculate function. ...
  • lbendlin's avatar
    3 years ago

    refactor your measure to isolate the individual computations.  

     

    Bestandsentwicklung (Absatzplan/VK Aufträge) = 
    var f = FILTER(
    		ALLSELECTED('Datumstabelle'[Date]),
    		ISONORAFTER('Datumstabelle'[Date], MAX('Datumstabelle'[Date]), DESC)
    	)
    var a = CALCULATE(sum('SCM Artikelbestand'[Menge])+sum('SCM FA-Zeile'[Restmenge])-sum('SCM ProdForecastEntry'[Absatzplanung]),f)
    var b = CALCULATE(sum('SCM Artikelbestand'[Menge])+sum('SCM FA-Zeile'[Restmenge])-sum('VK OffeneAuftraege'[Restmenge]),f)
    return if (sum('SCM ProdForecastEntry'[Absatzplanung]) > sum('VK OffeneAuftraege'[Restmenge]),a,b) 
    

     

    That way it is easier to troubleshoot. 

    Also - read about EVALUATEANDLOG - it's a game changer.