Forum Discussion

Vsaez's avatar
Vsaez
Frequent Visitor
5 years ago

Problem to filter visual

Hello, I hope you are well

I have a column, called Year_Month, where I have a combination between the year and the month, for example 202101, 202102, etc etc

I have to filter a visual by two values from this column, 202105 and 202005:



I made a measure in DAX to filter it, which is the following:

Comparacion_Dia =
CALCULATE (
SUM ( '20 Medidas Reclamos'[Reclamo] ),
FILTER ('01 Tiempo Creación',
'01 Tiempo Creación'[Año Mes] = "202105" || '01 Tiempo Creación'[Año Mes] = "202005"
)
)

This formula works, but it has the dates as string type
So, I did this measurement in DAX so that based on current date it will calculate the value I need, for this year and last year.

 

Filtro Año Mes Actual =
VAR Fecha_actual=MAX('01 Tiempo Creación'[Date])
RETURN

IF(
LEN(MONTH(Fecha_actual))=1,
YEAR(Fecha_actual)&0&MONTH(Fecha_actual),
YEAR(Fecha_actual)&MONTH(Fecha_actual))
 
This measure gives me the value 202105, which was what I needed. However, when I replace this measure with the string I had in the previous measure, the filter doesn't work for me ...

Does anyone know why that will happen?

Thank you!

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Vsaez A guess but check your data types and make sure that everything is a string and that you don't have a whole number data type in there for some reason. If you do, try adding & "" to it to force it to a string.

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, Vsaez 

     

    Is your problem been solved? I see that you didn't follow up. Have you checked the reply of others?

    According to you description, The result of your two measures is not one thing, one is the value of sum, and the other is to return date. So I don't understand your question very well, Can you explain it in detail? Or share more information like your modified code,etc. So we can help you soon.

     

    Best Regards

    Janey Guo

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.