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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
afbraga66
Helper III
Helper III

Filtering a constant value

Hello,


I am new to Power BI, so my question is that why this measure example returns 3 rows in a table, while I expected it to return only 1 row. I do not understand how to filter constant values.  Thank you.

afbraga66_0-1657121689937.png

 

Best regards,

André

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @afbraga66 ,
According to offical document, CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])

https://docs.microsoft.com/en-us/dax/calculate-function-dax


Calculate ([column]) or average or count... as 1 is a constant.so we could change it to:

 

 

Measure = IF(MAX('Dim_PLANT'[Plant_Code])="P058",1)

 

 

The final show:

vyalanwumsft_0-1657702681939.png

Or 

 

 

Measure 2 = CALCULATE(COUNT(Dim_PLANT[Plant_Code]),FILTER('Dim_PLANT',[Plant_Code]="P058"))

 

 

The final show:

vyalanwumsft_1-1657702753542.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-yalanwu-msft
Community Support
Community Support

Hi, @afbraga66 ,
According to offical document, CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]])

https://docs.microsoft.com/en-us/dax/calculate-function-dax


Calculate ([column]) or average or count... as 1 is a constant.so we could change it to:

 

 

Measure = IF(MAX('Dim_PLANT'[Plant_Code])="P058",1)

 

 

The final show:

vyalanwumsft_0-1657702681939.png

Or 

 

 

Measure 2 = CALCULATE(COUNT(Dim_PLANT[Plant_Code]),FILTER('Dim_PLANT',[Plant_Code]="P058"))

 

 

The final show:

vyalanwumsft_1-1657702753542.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

vapid128
Solution Specialist
Solution Specialist

You are calculating 1, in whatever case.

It gives you back 1.

If you calculat a measure like countrows(table), and the countrows filter by case

then it will get different numbers.

 

tamerj1
Super User
Super User

@afbraga66 

Ok. Please try

SUMX (
VALUES ( PlantCode ), 

IF ( PlantCode = "p058", 1 )

)

@tamerj1 Ok, that works. I'll try to apply that concept to what I really have to do. That was just an example to express the idea of what I was trying to do. Still, can you explain why the other methods do not work? Thank you.

 

Best regards, André

@afbraga66 

CALCULATE replaces the filter with the new filter inside it. So it replaces P051 with P059 and so on for all plant codes. What I don't understand why the KEEPFILTERS function didn't work with constant value as it KEEPFILTERS keeps the original filter and the intersection between the old the new filter leaves blank tables at all plant codes except P059. 
With SUMX we manually return blank if the code is not P059

tamerj1
Super User
Super User

Hi @afbraga66 

try replace FILTER with KEEPFILTERS but delete table name reference 

Same, doesn't work.

afbraga66_0-1657123231992.png

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.