Forum Discussion

Analitika's avatar
Analitika
Icon for Post Prodigy rankPost Prodigy
1 year ago

Wrong visual filtering in Power BI

Hello,

 

I have a problem 

 

When selecting column in first visual, I am getting wrong visual in second visual. Second visual sum is 58163 while first visual shows 35 286. Both visuals use same measure like this:

 

Prekės likutis, EUR (KATEGORIJA) = 

    CALCULATE (
       [Likutis, Eur],
        FILTER (
            DISTINCT (ALL(I27[I27_KODAS_PS] )),
            COUNTROWS (
                FILTER (
                   'Pasirinkti_sandeliams',
                   [17_1_1_Pasiskirstymas pagal kategorijas]='Pasirinkti_sandeliams'[Kategorijos]
                )
            ) > 0
        )
    )

Kategorijos are 

Kategorijos ar categories: filter final sum by category. So what I am doing wrong?

 

4 Replies

  • Hi

     

    It looks like the issue is coming from how the filters are being applied in your DAX measure, especially when using ALL('Date') inside your CALCULATE. When you do this, you’re removing all date filters, which can accidentally ignore your category context and give the wrong totals in your visuals.

     

    To make sure your measure respects the selected category in the visual, I recommend using KEEPFILTERS along with VALUES. This ensures that the measure only calculates within the current filter context (like the category selected in your chart or slicer).\

     

    Try updating your measure like this (replace table/column names as needed):

     

    Suma kategorimai =
    CALCULATE(
        [Suma],
        FILTER(
            ALL('Date'),
            'Date'[Date] <= MAX('Date'[Date])
        ),
        KEEPFILTERS(VALUES('Kategorija'[KategorijaID]))
    )
    

     

    This pattern will ensure you always get the correct total for the selected category in each visual, even with slicers or multiple charts on the page. If you want the measure to also respect page and report filters, you can use ALLSELECTED('Date') instead of ALL('Date') in your FILTER.

     

    Also, double-check that your relationships between tables are correct and active.

    • Analitika's avatar
      Analitika
      Icon for Post Prodigy rankPost Prodigy

      HI,

       

      After I am getting the same result. Here example:

       

      The result of second visual is 34450 instead of 27789. Why I am getting wrong filtering.

       

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Analitika ,

     

    Are the fields of both visualizations the same table? Could you please provide some example data? What are the parameters in your DAX?

     

     

     

    Best regards,

    Mengmeng Li

    • Analitika's avatar
      Analitika
      Icon for Post Prodigy rankPost Prodigy
      Likutis, Eur = [Suma kaupiamas]+sum(I27[I27_PIN_SUMA])
      Suma kaupiamas = CALCULATE(sum('I27'[I27_PIN_SUMA]), FILTER(ALL('Date'[Date]),'Date'[Date]<MIN('Date'[Date])))
       
       
       
       
      Here formulaes