March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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))
)
Solved! Go to Solution.
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
just add a "+0" at the end of your CALCULATE()
@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 this shows an error
@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()
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |