Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Condition based date range data loading based on month selection

Hi all,

 

              Creating a report using Postgresql DB.Table Visual data is loading using folllowing sample query. 

 

select column1,colum2,expiry_date,effective_date from table where expiry_date>='09/30/2022'
and expiry_date<'09/30/2023' and effective_date<='09/30/2022'.

 

Here for reference taken a sample query for the september month  data. But i will have  all month data as backup. Using  a month slicer here.

User will select a month from slicer .Suppose selected is october month means ,data should be take from expiry_date>='09/30/2022'
and expiry_date<'09/30/2023' and effective_date<='09/30/2022'.

 

Previous month date range data should be load in table visual.

Is it possible?

 

 

 

 

 

  • Hi, Anonymous 

    If you have a seperate Calendar table, you can put a measure to the table visual filter pane to filter data.

    filter = 
    VAR _date =
        EDATE ( MAX ( 'Calendar'[Date] ), -1 )
    VAR a =
        IF (
            MAX ( 'Fact Table'[effective_date] ) <= _date
                && MAX ( 'Fact Table'[expiry_date] ) >= _date
                && MAX ( 'Fact Table'[expiry_date] ) < EDATE ( _date, 12 ),
            1,
            0
        )
    RETURN
        IF ( ISFILTERED ( 'Calendar'[Date].[Month] ), a, 1 )

    Please check my sample for more details.

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

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

    Hi, Anonymous 

    If you have a seperate Calendar table, you can put a measure to the table visual filter pane to filter data.

    filter = 
    VAR _date =
        EDATE ( MAX ( 'Calendar'[Date] ), -1 )
    VAR a =
        IF (
            MAX ( 'Fact Table'[effective_date] ) <= _date
                && MAX ( 'Fact Table'[expiry_date] ) >= _date
                && MAX ( 'Fact Table'[expiry_date] ) < EDATE ( _date, 12 ),
            1,
            0
        )
    RETURN
        IF ( ISFILTERED ( 'Calendar'[Date].[Month] ), a, 1 )

    Please check my sample for more details.

     

    Best Regards,
    Community Support Team _ Eason
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Using postgresql database creating a report in power bi.  Database select query contain some date conditions like below

    Plcy_exp_date>='09/30/2022' and Plcy_exp_date<'09/30/2023' And "EFF_DATE"<='09/30/2022' .

    So, I have slicer in report which having month values.If the user select a month ,it will load based on the date condition above.

    Is there any way to do?