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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

blank keyword

i tried this expression for last year sales but this shows BLANK instead of 0 .. how to show 0 when there is no amount/data

 

expression

last_year_sales = var current_year= YEAR(MAX(Data[Date Main])) return  CALCULATE(SUM(Data[Net Sales]) ,(FILTER(Data,Data[Year]=current_year -1))
)
1 ACCEPTED SOLUTION

just add a "+0" at the end of your CALCULATE()

View solution in original post

8 REPLIES 8
lukiz84
Memorable Member
Memorable Member

Hi,

 

last_year_sales =
   var current_year= YEAR(MAX(Data[Date Main]))
   return
      CALCULATE(
         SUM(Data[Net Sales]), 
         (FILTER(Data,Data[Year]=current_year -1))
      )+0
Anonymous
Not applicable

@lukiz84 this shows an error also 

bakhtawarashiq_1-1663925927485.png

 

just add a "+0" at the end of your CALCULATE()

Anonymous
Not applicable

@Anonymous 

last_year_sales =
VAR current_year =
    YEAR ( MAX ( Data[Date Main] ) )

VAR previous_year = 
    CALCULATE (
        SUM ( Data[Net Sales] ),
        (
            FILTER ( Data, Data[Year] = current_year - 1 )
        )
    )

RETURN

if(previous_year = "", 0, previous_year)


Try this


This can't work because previous_year is a number. You can't compare a number to a string. You could only compare it to blank

 

IF(ISBLANK(previous_year), 0, previous_year)

Anonymous
Not applicable

@Anonymous this shows an error 

bakhtawarashiq_0-1663925806570.png

 

Anonymous
Not applicable

@Anonymous 

last_year_sales =
VAR current_year =
    YEAR ( MAX ( Data[Date Main] ) )

VAR previous_year = 
    CALCULATE (
        SUM ( Data[Net Sales] ),
        (
            FILTER ( Data, Data[Year] = current_year - 1 )
        )
    )

RETURN

if(previous_year <= 0, 0, previous_year)


Try this instead

this won't help either. <= 0 is not BLANK()

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.