Forum Discussion

MarioJoseb1980's avatar
MarioJoseb1980
Frequent Visitor
2 years ago
Solved

Creating a table with filtered values using a date from and date to

Hi this is not working for me. I am creating a table using this dax: 

EventosFiltrados =
FILTER('Eventos Agosto',
       'Eventos Agosto'[Fecha Inicio Evento] <= [SelectedDate]  &&  'Eventos Agosto'[Fecha Fin Evento] >= [SelectedDate]  
      )  
 
My [SelectedDate]  is a selectevalue from another table. This measure works fine: 
SelectedDate = SELECTEDVALUE('100 Horas Críticas SIN 2023'[Fecha Hora])
 
Please HELPPP!!!
  • Anonymous's avatar
    Anonymous
    2 years ago

    hi MarioJoseb1980 ,
    I delete the relationship and edit the DAX formula.

     

    Filter_date = 
    VAR dat = SELECTEDVALUE('100 HORAS CRITI'[Date])
    VAR hou = SELECTEDVALUE('100 HORAS CRITI'[Hour])
    VAR filter_dat = FILTER('Event_Table', 'Event_Table'[Start Date] <= dat && 'Event_Table'[Start Hour] <= hou && 'Event_Table'[End Date] >= dat && 'Event_Table'[End Hour] >= hou)
    RETURN
    CALCULATE(SUM('Event_Table'[Generation reserve]), filter_dat)

     

    The result is shown below.

     

    You need to be a super user to attach files on messages.

    Solved: How to upload PBI in Community - Microsoft Fabric Community

     

    Best Regards,

    Wisdom Wu

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

     

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi MarioJoseb1980 ,

    Please try the following methods and check if they can solve your problem:

    1.Create the simple table.

    2.Create the new measure to select date and hour.

     

    SELECTDATE = SELECTEDVALUE('100 HORAS CRITI'[Date])
    Selectedhour = SELECTEDVALUE('100 HORAS CRITI'[Hour])

     

    3.Create the new measure to filter values.

     

    Filter_date = 
    VAR dat = [SELECTDATE]
    VAR hou = [Selectedhour]
    VAR filter_dat = FILTER('Event_Table', 'Event_Table'[Start Date] <= dat && 'Event_Table'[Start Hour] <= hou && 'Event_Table'[End Date] >= dat && 'Event_Table'[End Hour] >= hou)
    RETURN
    CALCULATE(SUM('Event_Table'[Generation reserve]), filter_dat)

     

    4.Drag the measure into the table visual. The result is shown below.

     

    Best Regards,

    Wisdom Wu

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

     

     

     

    • MarioJoseb1980's avatar
      MarioJoseb1980
      Frequent Visitor

      What I want to return is a table in the right side with the list of the events contained in the date and hour from the right side. 

      I converted all the dates in short dates using format (for testing purposes) and did the following, but it didn't work: 

      EventosFiltrados =
      var shortDate = [SelectedDate]
      var shortTime = [SelectedHour]
      var filter1 = FILTER('Eventos Agosto',
             'Eventos Agosto'[FechaInicioCorta] <= shortDate && 'Eventos Agosto'[FechaFinCorta] >= shortDate  
            )      
      return CALCULATETABLE('Eventos Agosto',filter1)
      • MarioJoseb1980's avatar
        MarioJoseb1980
        Frequent Visitor

        Another important thing: both tables "100 Horas Criticas" and "Eventos Agosto" doesn't have a relationship. In your example you are creating a relationship between them, which is not the current situation.