Forum Discussion

renanmury's avatar
renanmury
Frequent Visitor
3 years ago

Filter error in DAX measures - SAMEPERIODLASTYEAR

Dear,

 

If any one could help me with this issue.. I'm facing this several times when I try to filter one of my parameters it gives me an error in one of my DAX measures, as below (at the end of the prints I wrote the measure formula):

 

When I use the "Field" filter, it gives me an error for each one:

 

The measure that I need to report is: 

Var 2023-2022 = DIVIDE([Calculation]-[Calculation Previous Year],[Calculation Previous Year])
 
And the parameters are as below:

Calculation =
SWITCH(
    TRUE(),
    [User selection (area)] = "Aviation", [Aviation CO2 (ton)],
    [User selection (area)] = "Marine", 'Atmosphere Emission - Vessels'[Gas amount (ton)],
    [User selection (area)] = "Road Transport", [Road Transport CO2 (ton)],
    [User selection (area)] = "Warehouse", [Warehouse CO2 (ton)],
    [User selection (area)] = "Total", [All Total CO2 (ton)],
    [All Total CO2 (ton)]
)
 
Calculation Previous Year =
SWITCH(
    TRUE(),
    [User selection (area)] = "Aviation", calculate([Aviation CO2 (ton)],SAMEPERIODLASTYEAR('Calendar'[Date])),
    [User selection (area)] = "Marine", calculate('Atmosphere Emission - Vessels'[Gas amount (ton)],SAMEPERIODLASTYEAR('Calendar'[Date])),
    [User selection (area)] = "Road Transport", calculate([Road Transport CO2 (ton)],SAMEPERIODLASTYEAR('Calendar'[Date])),
    [User selection (area)] = "Warehouse", calculate([Warehouse CO2 (ton)],SAMEPERIODLASTYEAR('Calendar'[Date])),
    [User selection (area)] = "Total", [All Total CO2 (ton) Previous],
    [All Total CO2 (ton) Previous]
)

All this measures are well related with the table Field (that is in the filter). I can't find a solution for this, could anyone help?
 
 

1 Reply