Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi Everyone,
I have the following DAX expression my issue is when I use this expression with le variable _Year is returns me a blank when I harcode the period I want example "2021.TOTAL", it is working and I do not understand what is the issue has I check the variable, if it is a text or a case issue but everything is align with what I need, any clue how to fix it ?
Act Previous Years = VAR default_year = YEAR(LASTDATE(ALL(DimDate[Date by Years])))-1
VAR selected_year = YEAR(SELECTEDVALUE('DimDate'[Date by Years]))-1
Var _Year = SWITCH(
TRUE(),
ISFILTERED(DimDate[Date by Years]),
CONCATENATE(CONVERT(selected_year,STRING), ".TOTAL"),
CONCATENATE(CONVERT(default_year,STRING), ".TOTAL")
)
VAR _Type = "ACTUAL - Actual"
VAR _Result = CALCULATE(
[Actual],
TREATAS(
{
_Year
},
'Data'[Period Available]
),
TREATAS(
{
_Type
},
'Data'[Type]
)
)
RETURN
_Result
You can do some debugging by creating individual measures for each part of your expression (like for default_year, selected_year, and _Year) and use them in a table visualization to see their individual outputs. This can help you pinpoint where the problem lies.
Proud to be a Super User!
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 36 | |
| 33 | |
| 31 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 86 | |
| 85 | |
| 68 | |
| 64 |