Forum Discussion

Renco's avatar
Renco
Advocate II
8 years ago
Solved

Filter table dynamicaly on dates

Hello community,

 

I'm trying to get a table (or measure) which is filtered through dates.

What I want to achieve is to filter the table on "begindatum" (which is starting date in English) and I only want to see the records which are currently active.

For example: today is the second of November, so what I need is all records which are active right now.

- I don't want to see the prices starting at the first of December

- I don't want to see the prices from the first of October if there is a price which starts at the first of November.

- I also want to filter the table on "Verkoopscode" RRPN.

 

This is just an example, but my real table is a lot larger than this. 

 

 
Basiccaly what I'm trying to do is creating a table where only one of each articlenumber is present and which contains the starting date closest to today (=today or earlier than today).

 

Thanks in advance for your help.

 

Regards,

Renco


  • Renco wrote:

    With an OData connection or any other 'import' connection this works like a charm. However with a DirectQuery connection this solution is not possible.

     

    So if someone knows another way to achieve this goal, suitable for a DirectQuery connection, I'm looking forward to hearing it.

     

    Thanks in advance.


    Renco

    In DirectQuery mode, say if the data source is SQL Server, you can create the columns in SQL instead of in Power BI desktop. Then you can still apply filter to the true/false column.

5 Replies

  • Renco's avatar
    Renco
    Advocate II

    This works:

     

     

    New Column in modelling tab:

     

    Datum = CALCULATE(LASTDATE(Klantenprijsgroep_Sheet[Begindatum]);ALLEXCEPT(Klantenprijsgroep_Sheet;Klantenprijsgroep_Sheet[Artikelnr.]);Klantenprijsgroep_Sheet[Begindatum]<=TODAY())

     

    With another column:

     

    Rapportage = IF(Klantenprijsgroep_Sheet[Begindatum]=Klantenprijsgroep_Sheet[Datum];true();false())

     

    And filtering in the visual itself on 'true'.

     

    Perhaps there is a better way than this but at least it's a solution

    • Eric_Zhang's avatar
      Eric_Zhang
      Microsoft Employee

      The solution is elegant, for me, I'll take the same solution. 

      • Renco's avatar
        Renco
        Advocate II

        With an OData connection or any other 'import' connection this works like a charm. However with a DirectQuery connection this solution is not possible.

         

        So if someone knows another way to achieve this goal, suitable for a DirectQuery connection, I'm looking forward to hearing it.

         

        Thanks in advance.