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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.