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

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

Reply
TechoGirl0
Frequent Visitor

Urgent help needed with variables

Hi,

I am an entry level powerBI developer and am trying to simplify this measure using variables. I have never done this with an IF statement. Any help/suggestions would be much appreciated.

 

MeasureX =
if(
CALCULATE(DISTINCTCOUNT(Program[ProgramStoreProduct]),
FILTER(Program, Program[Non Compliant]=1)
)=BLANK()
,BLANK()
,CALCULATE(DISTINCTCOUNT(Program[ProgramStoreProduct]),
FILTER(Program, Program[Non Compliant]=1)))
2 REPLIES 2
tackytechtom
Super User
Super User

Hi @TechoGirl0 ,

 

Do you mean something like this? 🙂

VAR _v1 =
CALCULATE ( 
    DISTINCTCOUNT ( Program[ProgramStoreProduct] ),
    FILTER ( Program, Program[Non Compliant] = 1 )
) RETURN IF ( _v1 = BLANK(), BLANK(), _v1 )

 

Let me know if this helps 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

No need for any variables for the above formula. And the simplest (and fastest) version is this:

 

calculate ( 
    distinctcount ( Program[ProgramStoreProduct] ),
    keepfilters ( Program[Non Compliant] = 1 )
)

 

By the way, this expression:

 

IF ( _v1 = BLANK(), BLANK(), _v1 )

 

is nothing else but simply...

 

_v1

 

 

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.