Forum Discussion

netanel's avatar
netanel
Icon for Post Prodigy rankPost Prodigy
4 years ago
Solved

If the cell is empty then insert "-"

Hey All!

 

I try to include in my Measure the condition that if the cell is empty
Then replace with "-" 
Can help?

 

Net USD AVG =

VAR NumDays=
CALCULATE (
DISTINCTCOUNT ('DB 2022'[Date] ),
KEEPFILTERS( 'Date'[Date] < TODAY() ),
NOT ISBLANK ( 'DB 2022'[Net USD]),
REMOVEFILTERS ( 'SORT GL' )
)

VAR SumNet =
CALCULATE (
SUM ( 'DB 2022'[Net USD]),
KEEPFILTERS( 'Date'[Date] < TODAY() )
)

RETURN DIVIDE (SumNet, NumDays)
  • Go on with VAR,

    ...
    VAR RES = DIVIDE (SumNet, NumDays)
    RETURN IF( ISBLANK(RES), "-", RES )
    

4 Replies

  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion

    netanel 

    if(isblank(measure/column),"-",required Dax) hope this helps!

    • netanel's avatar
      netanel
      Icon for Post Prodigy rankPost Prodigy

      VijayP 

      Of course I tried if isblank
      But I can not incorporate this correctly in my Measure

  • VijayP's avatar
    VijayP
    Icon for Community Champion rankCommunity Champion

    netanel  try this

    VAR NumDays=
    IF(ISBLANK(DISTINCTCOUNT ('DB 2022'[Date] ),"-",
    CALCULATE
     (
    DISTINCTCOUNT ('DB 2022'[Date] ),
    KEEPFILTERS( 'Date'[Date] < TODAY() ),
    NOT ISBLANK ( 'DB 2022'[Net USD]),
    REMOVEFILTERS ( 'SORT GL' )
    )
     
    and also in divide function use this and see whether you are getting final out come
    if in the place of denominator if you get "-" , then accordingly rest of the measure will take care

    RETURN DIVIDE (SumNet, NumDays,"-") 

  • CNENFRNL's avatar
    CNENFRNL
    Icon for Community Champion rankCommunity Champion

    Go on with VAR,

    ...
    VAR RES = DIVIDE (SumNet, NumDays)
    RETURN IF( ISBLANK(RES), "-", RES )