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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate Current Year Sales

Hi Experts

 

I am trying to calculate current year Sales Dynamically - I am using the following measure which is returning zero..

CurrentYear = CALCULATE(
SUM('Test Data'[sales]),
FILTER(ALL(
'Test Data'),YEAR('Test Data'[sales])=YEAR(TODAY())))
 
I have a DimDate Table which link to my Sales Table.....
Date
Year     Date Sales
2020
2020
2021
2021
 
 
1 ACCEPTED SOLUTION
Angith_Nair
Helper V
Helper V

Hi @Anonymous ,

First of all create a calculated column in Test Data table like this..

 

IsCurrentYear =
VAR TodayDate =
    TODAY ()
VAR CurrentYear =
    YEAR ( TodayDate )
RETURN
    'Test Data'[Date Column] >= DATE ( CurrentYear, 01, 01 )

 

This column will return true or false..

After this create a measure like this...

 

Measure =
VAR CurrentYearSales =
    CALCULATE ( SUM ( 'Test Data'[sales] ), 'Test Data'[IsCurrentYear] = TRUE () )
RETURN
    IF ( CurrentYearSales = BLANK (), 0, CurrentYearSales )

 

If this works, kindly mark it as a solution. Appreciate with Kuddos.

View solution in original post

3 REPLIES 3
Krutigawale33
Responsive Resident
Responsive Resident

Hello @Anonymous ,

 

try with the measure

CurrentYear = CALCULATE(
SUM('Test Data'[Sales]),
FILTER(ALL(
'Test Data'),'Test Data'[Year]=YEAR(TODAY())))

Angith_Nair
Helper V
Helper V

Hi @Anonymous ,

First of all create a calculated column in Test Data table like this..

 

IsCurrentYear =
VAR TodayDate =
    TODAY ()
VAR CurrentYear =
    YEAR ( TodayDate )
RETURN
    'Test Data'[Date Column] >= DATE ( CurrentYear, 01, 01 )

 

This column will return true or false..

After this create a measure like this...

 

Measure =
VAR CurrentYearSales =
    CALCULATE ( SUM ( 'Test Data'[sales] ), 'Test Data'[IsCurrentYear] = TRUE () )
RETURN
    IF ( CurrentYearSales = BLANK (), 0, CurrentYearSales )

 

If this works, kindly mark it as a solution. Appreciate with Kuddos.

Anonymous
Not applicable

Thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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