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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Current year blank values

In data there is a year 2021 only. i am trying to do analysis last and current year 

Current 2022 year is going .. and when i try this measure this shows that 

 

current year sales 0

last year sales 50.86 M

 

whereas according to data current year is 2021 .. so this should be 

current year 50.86

last year sales 0

 

how i do this 

 

i tried these expression

 

Current_year_sales = CALCULATE(SUM(Data[Net Sales]),FILTER(Data,Data[Year]=MONTH(TODAY())))

last_year_sales = var current_year= YEAR(TODAY()) return  CALCULATE(SUM(Data[Net Sales]),FILTER(Data,Data[Year]=current_year -1))

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

2020.1.1 – 2021.12.31

vyangliumsft_0-1664169333353.png

Here are the steps you can follow:

1. Create measure.

last year sales =
var _maxdate=
MAXX(ALL('Table'),[Date])
return
IF(
SUMX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(_maxdate)-1),[Column])=BLANK(),0)
current year =
var _maxdate=
MAXX(ALL('Table'),[Date])
return
SUMX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(_maxdate)),[Column])

2. Result:

vyangliumsft_1-1664169333355.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @Anonymous ,

I created some data:

2020.1.1 – 2021.12.31

vyangliumsft_0-1664169333353.png

Here are the steps you can follow:

1. Create measure.

last year sales =
var _maxdate=
MAXX(ALL('Table'),[Date])
return
IF(
SUMX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(_maxdate)-1),[Column])=BLANK(),0)
current year =
var _maxdate=
MAXX(ALL('Table'),[Date])
return
SUMX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(_maxdate)),[Column])

2. Result:

vyangliumsft_1-1664169333355.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

MahyarTF
Memorable Member
Memorable Member

Hi,

If the maximum date is for the last year(2021), you could use the Max(date) against the Today().

When you use Month(Today()) in your DAX, the 2022 is the result for current year.

Appreciate your Kudos and please mark it as solution if it helps

Mahyartf
Anonymous
Not applicable

@MahyarTF  ok i did this but this shows "blank" where as i want if amount is 0 then i want to show 0 instead of BLANK .. i tried this 

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

Hi,

If the issue for the current year is fixed, for the blank value you could use the if(isblank(...),0,...) in your dax like below :

Curreny_Year_sales =
Var Curr_Sales = CALCULATE(sum(Sheet211[Sales]), filter(sheet211, Sheet211[Date].[Year] = year(TODAY())))
return if(ISBLANK(Curr_Sales), 0, Curr_Sales)
Mahyartf
amitchandak
Super User
Super User

@Anonymous , With help from separate date or year table

 

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

 

Based on today

 

This year Today =
var _min = eomonth(today(),-1*month(today()))+1
var _max = eomonth(_min,11)
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Last year Today =
var _max = eomonth(today(),-1*month(today()))
var _min = eomonth(_max,-12)+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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