Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Formula not working as expected when using not equal combined with OR (||) operator

Hi,
 
I'm fairly new to power bi. I've been using this tool for about 5 months. I am trying to create a measure to calculate the total amount based on specific values. The values range from 1-20. I would like the measure to sum the total of a column for values 5-20. I think the best way to write this formula is to use "not equal" (<>) to filter out value 1-4 and my formula is found below. However, the measure is not working as expected and is summing the total based on values 1-20 I tried to filter out 1-4 using the not equal (<>). Please note that the column with the values 1-20 is in text and I've used the values formula to covert that column into numbers.
 
Can someone please take a look at my formula below and advise why it might not be working?
 

Total = CALCULATE(SUM('Mock 1042 Data'[Box 2 Amount]),FILTER('Mock 1042 Data', VALUE('Mock 1042 Data'[Unique Form ID]) <> 01 || VALUE('Mock 1042 Data'[Unique Form ID]) <> 02 || VALUE('Mock 1042 Data'[Unique Form ID]) <> 03 || VALUE('Mock 1042 Data'[Unique Form ID]) <> 04))

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi all,

 

I was able to solve this issue by replacing the OR operator (<>) with the AND operator (&&). This seem to work and I'm getting the correct results from the measures. Thanks for all your help. 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi all,

 

I was able to solve this issue by replacing the OR operator (<>) with the AND operator (&&). This seem to work and I'm getting the correct results from the measures. Thanks for all your help. 

amitchandak
Super User
Super User

Remove "VALUE" and check

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi,

I removed the "value" from the formula and got the below error. It's because the field that I using the apply the filter is set as a "text", which is why I'm using "VALUES"

Error Message:
MdxScript(Model) (16, 132) Calculation error in measure 'Mock 1042 Data'[Total]: DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

Below is my updated formula:
Total = CALCULATE(SUM('Mock 1042 Data'[Box 2 Amount]),FILTER('Mock 1042 Data','Mock 1042 Data'[Unique Form ID] <> 1 ||'Mock 1042 Data'[Unique Form ID] <> 2 ||'Mock 1042 Data'[Unique Form ID] <> 3 ||' Mock 1042 Data'[Unique Form ID] <> 4))

Any additional help to get this formula working would be grealy appreciated

Check the data type of your column. Make sure to make them the correct data type.  In case it is text type uses A<> "1".

 

Data Format.png

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks. I checked the data type and it'showing as "Text". I've updated my code to use quotes around the values that I'm filtering. Unforunately, the formula is still not excluding values 1-4 from the measure. 

 

Below is the updated formula.

Total = CALCULATE(SUM('Mock 1042 Data'[Box 2 Amount]),FILTER('Mock 1042 Data','Mock 1042 Data'[Unique Form ID] <> "1" ||'Mock 1042 Data'[Unique Form ID] <> "2" ||'Mock 1042 Data'[Unique Form ID] <> "3" ||'Mock 1042 Data'[Unique Form ID] <> "4"))

 

I've provided a screen shot example of what I'm trying to accomplish. In my example I should see a total of 8 but my measure is showing 12, which is not correct.

 

Error.PNG

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.