Forum Discussion

aristen's avatar
aristen
Frequent Visitor
9 years ago
Solved

Conditional filtering date ranges - Help with import

Hey all. Let me just start out by saying i am no expert in Dax/Power query, so if there is an obvious solution to my problem, i apologize.    I have made a custom visual where I import data as a t...
  • v-ljerr-msft's avatar
    v-ljerr-msft
    9 years ago

    Hi aristen,


    So if the user selects 10.feb to 15.feb i would still get values from FactMeteorologyTimeseries from 01.Jan and forward.

    Do you know why this is ?


    Not like measures, calculate columns/tables are computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report.

     

    In your scenario, you should use the formula to create a measure similar like below, then show the measure on the Table/Matrix visual with the corresponding columns from your table(or use the measure as visual level filter with Expand Date for T3 is not blank ). :smileyhappy:

     

    Expand Date for T3 =
    VAR minDateSelected = DimDate[min]
    VAR maxDateSelected = DimDate[max]
    VAR tenDaysPrevious = minDateSelected - 10
    VAR tenDaysAfter = maxDateSelected + 10
    RETURN
        COUNTROWS (
            FILTER (
                'dpv FactMeteorologyTimeSeries';
                'dpv FactMeteorologyTimeSeries'[ForecastTime].[Date]
                    >= DATE ( YEAR ( 'dpv FactMeteorologyTimeSeries'[ForecastTime].[Date] ); MONTH ( tenDaysPrevious ); DAY ( tenDaysPrevious ) )
                    && 'dpv FactMeteorologyTimeSeries'[ForecastTime].[Date]
                        <= DATE ( YEAR ( 'dpv FactMeteorologyTimeSeries'[ForecastTime].[Date] ); MONTH ( tenDaysAfter ); DAY ( tenDaysAfter ) )
            )
        )
    

    Regards