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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Ivancito111
Resolver I
Resolver I

Occupy a variable with a table name

Hello, good afternoon, I am writing to you because I have a question about a table filter.
What happens is that I have a value that changes by month and day, ie, today we are in September 20, I need to display the value with these two filters.

 

DiaEneroFebreroMarzoAbrilMayoJunioJulioAgostoSeptiembre

12222333336444495555126666157777188888219999251110
22222333336444495555126666157777188888219999251110
32222333336444495555126666157777188888219999251110
42222333336444495555126666157777188888219999251110
52222333336444495555126666157777188888219999251110
62222333336444495555126666157777188888219999251110
72222333336444495555126666157777188888219999251110
82222333336444495555126666157777188888219999251110
92222333336444495555126666157777188888219999251110
102222333336444495555126666157777188888219999251110
112222333336444495555126666157777188888219999251110
122222333336444495555126666157777188888219999251110
132222333336444495555126666157777188888219999251110
142222333336444495555126666157777188888219999251110
152222333336444495555126666157777188888219999251110
162222333336444495555126666157777188888219999251110
172222333336444495555126666157777188888219999251110
182222333336444495555126666157777188888219999251110
192222333336444495555126666157777188888219999251110
202222333336444495555126666157777188888219999251110
212222333336444495555126666157777188888219999251110
222222333336444495555126666157777188888219999251110
232222333336444495555126666157777188888219999251110
242222333336444495555126666157777188888219999251110
252222333336444495555126666157777188888219999251110
262222333336444495555126666157777188888219999251110
272222333336444495555126666157777188888219999251110
282222333336444495555126666157777188888219999251110
292222333336444495555126666157777188888219999251110
302222333336444495555126666157777188888219999251110
31  64444 126666157777 219999 

 

and so on with all the months and days of the month.

In what I have researched I managed to filter by day (today's 20th), but I still can't do it by month.

Ivancito111_0-1632146697589.png

I remain attentive to any comments that allow me to do so.

1 ACCEPTED SOLUTION

@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.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@Ivancito111 You would likely have better luck if you unpivoted your month columns in Power Query.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

But I still have the problem that it must choose the column depending on the month in which we are.

@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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I know that your answer solves my problem, but isn't there a method that doesn't ruin my board?

@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.

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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