Forum Discussion

Fsciencetech's avatar
Fsciencetech
Helper III
5 years ago

Earlier Function

Hi All,

 

Need your help to resolve one logic on dax.

 

Trying on DAX as below but getting error -"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value"

 

SWITCH( TRUE(), FILTER(OSMS_Recomit, OSMS_Recomit[OSMaterialRecoveryDate] = EARLIER(OSMS_Recomit[OSMaterialRecoveryDate])), "Same", FILTER(OSMS_Recomit, OSMS_Recomit[OSMaterialRecoveryDate] > EARLIER(OSMS_Recomit[OSMaterialRecoveryDate])),"Pushout", FILTER(OSMS_Recomit, OSMS_Recomit[OSMaterialRecoveryDate] < EARLIER(OSMS_Recomit[OSMaterialRecoveryDate])),"PullIn","NA" )

 


  

 

4 Replies

  • MattAllington's avatar
    MattAllington
    Community Champion

    the formula looks fundamentally flawed to me. Lines 4-8 (the filter) return a table. But you are using switch true, so this section must return a true/false expression, not a table. The same applies to the other sections. 

  • Hi Matt,

    Thanks for your reply,

    Suppose the IF condition, The below logic is not realted to DAX function, only explaing the logic that How can implement on DAX

     

    If(OSMaterialRecoveryDate = Previous(OSMaterialRecoveryDate), "Same",

    If(OSMaterialRecoveryDate > Previous(OSMaterialRecoveryDate), "Pushout",

    If(OSMaterialRecoveryDate < Previous(OSMaterialRecoveryDate), "Pullin","NA")))

    • MattAllington's avatar
      MattAllington
      Community Champion

      What do you mean by "Previous"?  What are you trying to do?  What tables and relationships do you have?

    • v-deddai1-msft's avatar
      v-deddai1-msft
      Community Support

      Hi Fsciencetech ,

       

      Use the followng measure based on your logic:

       

      
      SWITCH(True(),OSMaterialRecoveryDate = Previous(OSMaterialRecoveryDate, "Same",
      
      OSMaterialRecoveryDate > Previous(OSMaterialRecoveryDate), "Pushout",
      
      OSMaterialRecoveryDate < Previous(OSMaterialRecoveryDate), "Pullin","NA")))

       

      If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

       

      Best Regards,

      Dedmon Dai