Forum Discussion

TechoGirl0's avatar
TechoGirl0
Frequent Visitor
4 years ago

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

    • daXtreme's avatar
      daXtreme
      Icon for Solution Sage rankSolution Sage

      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