Forum

Notifications
Clear all

DAX SUM with OR.

3 Posts
3 Users
0 Reactions
166 Views
(@countryfan_nt)
Posts: 18
Eminent Member
Topic starter
 

Hello friends, Hope all is well!

Please help me with the below DAX formula.

Trying to have the OR function applied. So if the field has either the word "Pharma" or "Hosp." then resume.

the below formula needs editing please. 

= CALCULATE(sum([amount]), FILTER( 'AP-RAW',[Hosp / Pharma]="Pharma"&&[Hosp / Pharma]="Hosp."&&[TRANSACTION_TYPE_NAME]=earlier([TRANSACTION_TYPE_NAME])&&[DESCRIPTION]=EARLIER([DESCRIPTION])))

 

Thank you so much in advance!

 
Posted : 15/03/2023 11:53 am
Riny van Eekelen
(@riny)
Posts: 1189
Member Moderator
 

Can't test it but the && logical operator equals an AND. Since you seem to need an OR, use || (a double pipe).
More on that in the link below.
https://learn.microsoft.com/en-us/dax/dax-operator-reference

 
Posted : 15/03/2023 12:34 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

You can also use the IN operator when you want to use OR logic.

CALCULATE(

       sum([amount]), 

       FILTER(

      'AP-RAW',

      [Hosp / Pharma] IN {"Pharma" , "Hosp."} && [TRANSACTION_TYPE_NAME]=earlier([TRANSACTION_TYPE_NAME]) && [DESCRIPTION]=EARLIER([DESCRIPTION]

      )

      )

)

Regards

Phil

 
Posted : 16/03/2023 7:08 pm
Share: