Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 months ago
Solved

Filters not works while selecting multiple Period

Hi Team,

 

I’m noticing an issue with the table visual when selecting multiple Years and Quarters. The results are not filtering correctly.

When multiple selections are applied, the table should always show the latest selected Quarter and the latest Month within that Quarter.

Example:
If the selected values include 2025‑Q4, 2026‑Q1, 2026‑Q1, and the latest Month = 3,
then the result displayed should correspond only to 2026‑Q1, Month 3.

Right now, the visual is not restricting the output to the latest period.

Requesting support to correct the filter logic so that the table always returns the most recent Year–Quarter and Month when multiple selections are made.

An example of the expected behavior is attached below

Total Value =

VAR LatestQuarterIndex =
CALCULATE(
MAX ( 'Calendar'[YYYY-QQ] ),
ALLSELECTED ( 'Calendar'[YYYY-QQ] )
)
VAR LatestYear =
MAXX(ALLSELECTED('Calendar'), 'Calendar'[Year])

VAR LatestQuarterNumInLatestYear =
CALCULATE(
MAX('Calendar'[Month Number]),
ALLSELECTED('Calendar'),
'Calendar'[Year] = LatestYear
)

VAR _EQ = SELECTEDVALUE('Table2'[EQ])
VAR _LY = SELECTEDVALUE('Table2'[LY])

RETURN
CALCULATE(SUM('Fact table'[amount]),
'Fact table'[Quarter] = LatestQuarterIndex,
'Fact table'[Month Number] = LatestQuarterNumInLatestYear,
'Fact table'[EQ]=_EQ,
'Fact table'[LY]=_LY)

 

  • Hi Anonymous,

    I tried to reproduce your scenario on my side using a small sample model and was able to get the expected output. In the PBIX I created a Calendar table with Year, Quarter and Month information and connected it with the fact table using those fields. Then I applied logic so that when multiple Years and Quarters are selected, the calculation always resolves to the latest Year, the latest Quarter within that Year, and the latest Month within that Quarter from the current selection.

    With this setup, even if multiple periods like 2025-Q4 and 2026-Q1 are selected, the table visual returns values only for the most recent period instead of aggregating older quarters.

    I am attaching the sample PBIX file for reference so you can check how the model behaves and compare it with your setup.

    Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
    Regards,
    Community Support Team.

10 Replies

  • Hello my friend,

     

    The issue is that SELECTEDVALUE returns BLANK when multiple rows are selected for EQ and LY — it only works with a single value. You need VALUES or just remove those vars and let the filter context handle it naturally.
    Also, your LatestQuarterNumInLatestYear is getting the latest month number across all selected quarters, but filtering on 'Fact table'[Month Number] directly — make sure that column exists and matches.
    Try this cleaner version:
    daxTotal Value =
    VAR LatestYYYYQQ =
    CALCULATE(
    MAX('Calendar'[YYYY-QQ]),
    ALLSELECTED('Calendar'[YYYY-QQ])
    )
    VAR LatestMonth =
    CALCULATE(
    MAX('Calendar'[Month Number]),
    ALLSELECTED('Calendar'),
    'Calendar'[YYYY-QQ] = LatestYYYYQQ
    )
    RETURN
    CALCULATE(
    SUM('Fact table'[amount]),
    'Fact table'[Quarter] = LatestYYYYQQ,
    'Fact table'[Month Number] = LatestMonth
    )
    The key changes: dropped SELECTEDVALUE for EQ and LY (let the visual's row context filter those naturally), and simplified the latest quarter/month logic into two clean vars. If EQ and LY still need explicit filtering, share what Table2 is — it looks like a disconnected table which would explain why SELECTEDVALUE was breaking things.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Juan-Power-bi 

      Hi Juan,

      Thanks for the update!

      We need one more enhancement in the logic — the EQ and LY filters must be applied directly on the fact table.

      Specifically:

      • Enterprise Quality (EQ) = Temp1, Temp2, Temp3
      • Life Span Year (LY) = year1, year2, year3

      These two filters are being applied on my side, and the sample dataset I shared is only a small version — the actual fact table is around 10 GB.

      I am still getting the same result using your DAX function as I was seeing earlier.
      Could you please take another look?

  • Hi Anonymous

     

    In your scenario, when several Years and Quarters are selected, the visual should always resolve to:
    the latest selected Year,
    the latest Quarter within that Year, and
    the latest Month within that Quarter,
    and then compute the measure only for that specific combination.
    The most reliable approach is to:
    Determine the latest Year in the current filter context.
    Determine the latest Quarter within that Year.
    Determine the latest Month within that Year–Quarter.
    Apply these three values as filters when calculating the measure.
    A revised version of the measure that follows this pattern is shown below.


    Total Value =
    VAR LatestYear =
    CALCULATE(
    MAX ( 'Calendar'[Year] ),
    ALLSELECTED ( 'Calendar' )
    )

    VAR LatestQuarter =
    CALCULATE(
    MAX ( 'Calendar'[Quarter Number] ),
    ALLSELECTED ( 'Calendar' ),
    'Calendar'[Year] = LatestYear
    )

    VAR LatestMonth =
    CALCULATE(
    MAX ( 'Calendar'[Month Number] ),
    ALLSELECTED ( 'Calendar' ),
    'Calendar'[Year] = LatestYear,
    'Calendar'[Quarter Number] = LatestQuarter
    )

    VAR _EQ = SELECTEDVALUE ( 'Table2'[EQ] )
    VAR _LY = SELECTEDVALUE ( 'Table2'[LY] )

    RETURN
    CALCULATE(
    SUM ( 'Fact table'[Amount] ),
    KEEPFILTERS ( 'Calendar'[Year] = LatestYear ),
    KEEPFILTERS ( 'Calendar'[Quarter Number] = LatestQuarter ),
    KEEPFILTERS ( 'Calendar'[Month Number] = LatestMonth ),
    'Fact table'[EQ] = _EQ,
    'Fact table'[LY] = _LY
    )


    Why this approach is more robust
    Avoids relying on SELECTEDVALUE for Calendar fields
    When multiple Years or Quarters are selected, SELECTEDVALUE for those columns returns BLANK, which breaks the logic. Using MAX over ALLSELECTED explicitly identifies the latest value within the current selection.
    Uses ALLSELECTED over the Calendar table
    ALLSELECTED('Calendar') considers only the periods that the user has chosen (including slicers and visual-level filters), but disregards row-level context in the visual, making it appropriate for computing “latest” values.
    KEEPFILTERS preserves user context
    By using KEEPFILTERS, we ensure that the measure does not remove other existing filters on the Calendar table, but rather narrows them down to the latest Year–Quarter–Month combination.
    Always resolves to the most recent period
    For a selection such as 2025‑Q4, 2026‑Q1, and 2026‑Q2 with Month 3 available in 2026‑Q2, the logic will correctly identify:
    Year = 2026
    Quarter = 2
    Month = 3
    and the measure will return values only for that final period.
    If your Calendar table uses different column names (for example YYYY-QQ instead of Quarter Number), the same pattern applies; you would simply adapt the column references accordingly.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      apply the same logic but getting error :

  • Hi,

    Try this measure pattern

    Last selected date = max(calendar[date])

    Amount in last selected quarter = calculate(sum(Data[sales]),datesbetween(calendar[date],eomonth([Last selected date],-3)+1,[Last selected date]))

    If this does not work, then share the download link of the PBI file.

  • Hi Anonymous 

    Doesn't your fact table have dates. This would have been simpler if calculation is based on actual dates.

    • Anonymous's avatar
      Anonymous
      Not applicable

      my bad, fact table doesn't have dates columns, I understood.

       

      I don't know how its works

  • v-hjannapu's avatar
    v-hjannapu
    Community Support

    Hi Anonymous,

    I tried to reproduce your scenario on my side using a small sample model and was able to get the expected output. In the PBIX I created a Calendar table with Year, Quarter and Month information and connected it with the fact table using those fields. Then I applied logic so that when multiple Years and Quarters are selected, the calculation always resolves to the latest Year, the latest Quarter within that Year, and the latest Month within that Quarter from the current selection.

    With this setup, even if multiple periods like 2025-Q4 and 2026-Q1 are selected, the table visual returns values only for the most recent period instead of aggregating older quarters.

    I am attaching the sample PBIX file for reference so you can check how the model behaves and compare it with your setup.

    Hope the above provided information help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
    Regards,
    Community Support Team.

    • v-hjannapu's avatar
      v-hjannapu
      Community Support

      Hi Anonymous,
      I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.

      Regards,
      Community Support Team.

      • v-hjannapu's avatar
        v-hjannapu
        Community Support

        Hi Anonymous,
        I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.

        Regards,
        Community Support Team.