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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
CamronBute
Frequent Visitor

CALCULATE() not filtering correctly?

Consider the following query result (in the Edit Queries screen):

image.png

 

Now here are two measures I have made on that query:

image.pngimage.png

 

This is the result:

image.png

 

I expected to see:

image.png

 

 

Am I missing something, or is this a bug?

2 ACCEPTED SOLUTIONS
tringuyenminh92
Memorable Member
Memorable Member

Hi @CamronBute,

 

To use these method or multiple conditions in filtering, please wrap them in Filter method

 

CALCULATE([Total Views],FILTER(Views,NOT(ISBLANK(Views[Who]))))

Capture.PNG

 

View solution in original post

OwenAuger
Super User
Super User

Hi @CamronBute

 

Two reasons I believe are contributing to your unexpected results:

  1. The empty values in the Who column are empty strings rather than null values (empty strings and nulls look the same in Data view, but are distinguishable in the Query Editor).
  2. CALCULATE filter arguments overwrite the filter context (by default) rather than intersecting with it.

Assuming the blank names are empty strings, this code should work:

 

 

Total authenticated views =
CALCULATE (
    [Total Views],
    Views[Who] <> "",
    VALUES ( Views[Who] )
)

 

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

4 REPLIES 4
OwenAuger
Super User
Super User

Hi @CamronBute

 

Two reasons I believe are contributing to your unexpected results:

  1. The empty values in the Who column are empty strings rather than null values (empty strings and nulls look the same in Data view, but are distinguishable in the Query Editor).
  2. CALCULATE filter arguments overwrite the filter context (by default) rather than intersecting with it.

Assuming the blank names are empty strings, this code should work:

 

 

Total authenticated views =
CALCULATE (
    [Total Views],
    Views[Who] <> "",
    VALUES ( Views[Who] )
)

 

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Yes, I see now. Thank you for explaining the behaviour I was missing, too.

tringuyenminh92
Memorable Member
Memorable Member

Hi @CamronBute,

 

To use these method or multiple conditions in filtering, please wrap them in Filter method

 

CALCULATE([Total Views],FILTER(Views,NOT(ISBLANK(Views[Who]))))

Capture.PNG

 

Yes, this works. Thank you!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.