Forum Discussion
Occupy a variable with a table name
- 4 years ago
Ivancito111 The only thing you are left with is a big long SWITCH statement like:
Measure = VAR __dia = DAY(TODAY()) VAR __month = MONTH(TODAY()) RETURN SWITCH(__month), 1, CALCULATE(SUMX('Tabla1', 'Tabla1'[Enero]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), 2, CALCULATE(SUMX('Tabla1', 'Tabla1'[Febrero]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), 3, CALCULATE(SUMX('Tabla1', 'Tabla1'[Marzo]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), ... )Also, the unpivoting would be in Power Query Editor, not in the source data.
Ivancito111 You would likely have better luck if you unpivoted your month columns in Power Query.
But I still have the problem that it must choose the column depending on the month in which we are.
- Greg_Deckler4 years ago
Community Champion
Ivancito111 If you unpivot the columns then no, you are simply filtering rows at that point. This is why it works better than having rows spread out across the table. If you unpivot then you should have:
Dia, Attribute, Value
1, Enero, 111
1, Februaro, 1111
So, all you have to do is filter Attribute for the month you want. No column selection needed, it is always Attribute.
- Ivancito1114 years ago
Resolver I
I know that your answer solves my problem, but isn't there a method that doesn't ruin my board?
- Greg_Deckler4 years ago
Community Champion
Ivancito111 The only thing you are left with is a big long SWITCH statement like:
Measure = VAR __dia = DAY(TODAY()) VAR __month = MONTH(TODAY()) RETURN SWITCH(__month), 1, CALCULATE(SUMX('Tabla1', 'Tabla1'[Enero]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), 2, CALCULATE(SUMX('Tabla1', 'Tabla1'[Febrero]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), 3, CALCULATE(SUMX('Tabla1', 'Tabla1'[Marzo]), FILTER('Tabla1','Tabla1'[Dia]=__dia)), ... )Also, the unpivoting would be in Power Query Editor, not in the source data.