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
ahmchiu
Frequent Visitor

Visual filter vs DAX Measure

Hi all,

 

I have set up the following measures to calculate the number of positive score as a % of total. Instead of including the filter (bold in the original method) to filter out the blank score in the measure, I tried to remove that from the measure but included it as a filter on visual (as shown in the amended method below) so that the measure can be used in other calculation too. While the denominator can be correctly filtered under the amended method, the non-blank values are not filtered out in the numerator. Any hints on why would that happened? 

 

Thank you so much in advance!

 

Original method

_% of id with positive score =
var _positivescore = CALCULATE(COUNT(contacts[id]),measurement[score] >= 0 && not(isblank(measurement[score])))
var _total = CALCULATE(COUNT(contacts[id]),not(isblank(measurement[score])))
return
DIVIDE(_positivescore,_total)
 
Amended method
_% of id with positive score =
var _positivescore = CALCULATE(COUNT(contacts[id]),measurement[score] >= 0)
var _total = COUNT(contacts[id])
return
DIVIDE(_positivescore,_total)
 
ahmchiu_0-1710724923132.png

 

5 REPLIES 5
Anonymous
Not applicable

@amitchandak  @Ashish_Mathur  Thanks for your contribution.

Hi @ahmchiu ,

@amitchandak provided some suggesiton on your problem. Have you gotten the soution? If yes, could you please mark your post as Answered? Otherwise, please provide some fake data to explain the requirement and your expected result just as @Ashish_Mathur suggested. Thank you.

Best Regards

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.  Also, show the incorrect answer and the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur sorry, cannot upload th PBI file.. it is connected to my database....

amitchandak
Super User
Super User

@ahmchiu , Try one of the two

 

divide(
countx(values(contacts[id]), if(measurement[score] >= 0 && not(isblank(measurement[score])), [id], blank())),
countx(values(contacts[id]), if( not(isblank(measurement[score])), [id], blank())) )

 

or


divide(
countx(values(contacts[id]), if(measurement[score] >= 0 && not(isblank(measurement[score])), [id], blank())),
calculate(countx(values(contacts[id]), if( not(isblank(measurement[score])), [id], blank())), allselected()) )

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

Instead of putting "&& not(isblank(measurement[score]))" within the DX formula, I am trying to remove it from the formula and replace it using a visual filter. Is it possible? 

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.

Top Solution Authors
Top Kudoed Authors