Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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()
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
105 | |
99 | |
99 | |
38 | |
37 |
User | Count |
---|---|
157 | |
121 | |
73 | |
73 | |
63 |