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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Syndicate_Admin
Administrator
Administrator

DAX Retrieve Year Value in a Virtual Table

Hello everyone

I have a table with values to display in a Segmenter and another table with target values.

GCM_9_0-1686321808688.png GCM_9_1-1686321827586.png

Depending on the selected year, only the values q appear in the T_Objetivo will be shown and if there is no record for that year, all the records of the T_DiasCierre are shown.

That seems to more or less work for me.

GCM_9_2-1686321883078.png

I have the problem when trying to retrieve the year value (SELECTEDVALUE(Calendar[Date].[ Year])) that does not retrieve any value.

finalCalc =

var anno = SELECTEDVALUE(Calendar[Date].[ Year])

WHERE _Filtered =

CALCULATE(SUM(T_Objetivo[VALOR]),T_Objetivo[AÑO] = anno && T_Objetivo[AMBITO] = "USER" && T_Objetivo[INDICADOR] = "CLOSED" )

VAR calculation =

ADDCOLUMNS (

GROUPBY (

T_U_DiasCierre,

T_U_DiasCierre[Id],

"Value", SUMX ( CURRENTGROUP (), [Value] )

),

"Active", IF(ISBLANK( _Filtered), 1,IF ( [Value] = _Filtered, 1 ))

,"ANNO", SELECTEDVALUE(Calendar[Date].[ Year])

,"a_calen",year

)

return calculo

GCM_9_3-1686321945755.png GCM_9_4-1686321957783.png

What can I do to solve this problem?

Thanks a lot

6 REPLIES 6
Syndicate_Admin
Administrator
Administrator

I have a Calendar table and from this table we show a filter with the different years that can be selected.
When you select a year, I'm trying to retrieve it with SELECTEDVALUE(Calendar[Date]. [Year],MAX(CALENDAR[year])), but in the virtual table does not retrieve any value for the year
I do not know if the virtual tables can not use values that come from some filter

Syndicate_Admin
Administrator
Administrator

I think the most logical thing would be that if we do not have a selected year we take the biggest
SELECTEDVALUE(Calendar[Date]. [Year],MAX(CALENDAR[year]))

Then do that.  MAX() is a good stand-in for SELECTEDVALUE() especially when the expected Total is also the last value.

Syndicate_Admin
Administrator
Administrator

The year value is taken from a slicer in the Calendar table

With the selected year you must create a new segmenter with only the active values

The year I am trying to retrieve with SELECTEDVALUE(Calendar[Date]. [Year]) but when you create the new virtual table you are not retrieving the selected year

GCM_9_1-1686552884189.png

finalCalc =
var anno = SELECTEDVALUE(Calendar[Date].[ Year])
VAR _Filtered =
CALCULATE(SUM(T_Objetivo[VALUE]),T_Objetivo[YEAR] = anno && T_Objetivo[SCOPE] = "USER" && T_Objetivo[INDICATOR] = "CLOSED" )
VAR calculation =
ADDCOLUMNS (
GROUPBY (
T_U_DiasCierre,
T_U_DiasCierre[id],
"Value", SUMX ( CURRENTGROUP(), [Value] )
),
"Active", IF(ISBLANK( _Filtered), 1,IF ( [Value] = _Filtered, 1 ))
,"ANNO", SELECTEDVALUE(Calendar[Date].[ Year])
,"a_calen",anno
)
return calculo

GCM_9_4-1686553608784.png

The result of the T_finalCal will be mostrarT_DiasCierre and a 1 will appear in the Active field if the value is in T_Objetivo

This is the initial approach, but I can modify it if someone gives me a good result


If there is no single year selected  SELECTEDVALUE will return BLANK()

lbendlin
Super User
Super User

SELECTEDVALUE from where?  Do you have a visual where the calendar date is used together with the measure?  If not then you may not have the right (or no) filter context.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors