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

measure to return/filter 3 columns

Hi guys,

 

I am trying to return and matrix table with 3 years as columns: last_year, this_year and next_year

 

I made the following measure:

 

Tons measure =
var this_year = YEAR(TODAY())
var previous_year = YEAR(TODAY())-1
var next_year = YEAR(TODAY()) +1
Return
SUMX(FILTER('Test Tabel', 'Test Tabel'[Date]={this_year, previous_year, next_year}),'Test Tabel'[Tons]
)
 
I get the error:  A table of multiple values was supplied where a single value was expected.
 
The expected result is :
 
Result tabel 1  
name202020212022
a147
b258
c369

 

Any help/tips are appreciated. Thanks in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,  Try one of the two ways

 

Tons measure =
var this_year = YEAR(TODAY())
var previous_year = YEAR(TODAY())-1
var next_year = YEAR(TODAY()) +1
Return
SUMX(FILTER('Test Tabel', 'Test Tabel'[Date] in {this_year, previous_year, next_year}),'Test Tabel'[Tons]
)

 

or


Tons measure =
var this_year = YEAR(TODAY())
var previous_year = YEAR(TODAY())-1
var next_year = YEAR(TODAY()) +1
Return
SUMX(FILTER('Test Tabel', 'Test Tabel'[Date]>= previous_year && 'Test Tabel'[Date]<= next_year}),'Test Tabel'[Tons]
)

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous ,  Try one of the two ways

 

Tons measure =
var this_year = YEAR(TODAY())
var previous_year = YEAR(TODAY())-1
var next_year = YEAR(TODAY()) +1
Return
SUMX(FILTER('Test Tabel', 'Test Tabel'[Date] in {this_year, previous_year, next_year}),'Test Tabel'[Tons]
)

 

or


Tons measure =
var this_year = YEAR(TODAY())
var previous_year = YEAR(TODAY())-1
var next_year = YEAR(TODAY()) +1
Return
SUMX(FILTER('Test Tabel', 'Test Tabel'[Date]>= previous_year && 'Test Tabel'[Date]<= next_year}),'Test Tabel'[Tons]
)

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.