Forum Discussion

MTrullàs's avatar
MTrullàs
Icon for Helper III rankHelper III
4 years ago
Solved

Percentil with filter

Hello world!

 

Yesterday, with the help of AlB I was able to solve a problem with the task Percentile

Today I have a new challenge with the same topic. I have to calculte the same measure with the differents filters of the table. 

 

So, I have that table with diferents columns, Fábrica, Campa, Semana, Mes, Año, Marca, with differents valuers. When I filter some valuer from the columns, the NewMesure_1 dosen't work, it appers the same valures that in general without filter.

 

Without filter the  NewMesure_1 works:

 

But, if I do a filter, it does not work because appears the same values.

 

 

The NewMesure_1 is:

 

NewMeasure_1 = 
VAR total_ = CALCULATE ( COUNT ( Tabla[Estancia Fábrica] ), ALL ( Tabla ) )
VAR currentEst_ = SELECTEDVALUE ( Tabla[Estancia Fábrica], total_ )
VAR cumul_ =
    CALCULATE (
        COUNT ( Tabla[Estancia Fábrica] ),
        Tabla[Estancia Fábrica] <= currentEst_,
        ALL ( Tabla )
    )
RETURN
DIVIDE ( cumul_, total_ )

 

 

And the example of the table is:

 

 

Fgstnr Fábrica Campa Semana Mes Año Marca Estancia Fábrica 1 Mar Sch 13 Abril 2022 Sea 1 2 Bar Sch 14 Abril 2022 Sea 2 3 Mar Sch 14 Abril 2022 Cup 3 4 Mar Sch 12 Abril 2022 Cup 4 5 Mar Sch 14 Abril 2022 Sea 1 6 Mar Sch 14 Abril 2022 Sea 2 7 Bar Sch 12 Abril 2022 Sea 3 8 Mar Sch 11 Abril 2022 Cup 4 9 Bar Sch 14 Abril 2022 Sea 1 10 Bar Sch 14 Abril 2022 Cup 2 11 Bar Sch 12 Abril 2022 Sea 1 12 Mar Sch 14 Abril 2022 Sea 1 13 Mar Sch 14 Abril 2022 Cup 2 14 Bar Sch 12 Abril 2022 Sea 1 15 Mar Sch 14 Abril 2022 Sea 0 16 Bar Sch 11 Abril 2022 Cup 1 17 Mar Sch 11 Abril 2022 Sea 1 18 Bar Sch 14 Abril 2022 Sea 0 19 Mar Sch 12 Abril 2022 Cup 1 20 Bar Sch 14 Abril 2022 Sea 2 21 Mar Sch 14 Abril 2022 Sea 0 22 Bar Sch 14 Abril 2022 Sea 0 23 Bar Sch 12 Abril 2022 Cup 0 24 Mar Sch 14 Abril 2022 Sea 1 25 Mar Sch 14 Abril 2022 Sea 1 26 Mar Sch 14 Abril 2022 Cup 1 27 Mar Sch 14 Abril 2022 Sea 2 28 Mar Sch 14 Abril 2022 Sea 2 29 Mar Sch 14 Abril 2022 Sea 2 30 Mar Sch 14 Abril 2022 Cup 2 31 Mar Sch 14 Abril 2022 Sea 2 32 Mar Sch 14 Abril 2022 Cup 1 33 Bar Sch 14 Abril 2022 Sea 1 34 Mar Sch 14 Abril 2022 Cup 1 35 Mar Sch 12 Abril 2022 Cup 1 36 Mar Sch 14 Abril 2022 Sea 1 37 Mar Sch 14 Abril 2022 Sea 1 38 Bar Sch 12 Abril 2022 Sea 1 39 Mar Sch 11 Abril 2022 Cup 1 40 Bar Sch 14 Abril 2022 Sea 2 41 Bar Sch 14 Abril 2022 Cup 1 42 Bar Sch 12 Abril 2022 Sea 1 43 Mar Sch 14 Abril 2022 Sea 1 44 Mar Sch 14 Abril 2022 Cup 1 45 Bar Sch 12 Abril 2022 Sea 1

 

Thhank you ver much!

  • Hi MTrullàs 

    It's the ALL(Tabla) that is overriding all the filters. Try this. If it doesn´t work, share the data in the same format as you did yesterday. Today's format is not good to copy

     

    NewMeasure_2 = 
    VAR total_ = CALCULATE ( COUNT ( Tabla[Estancia Fábrica] ), ALL ( Tabla[Estancia Fábrica]) )
    VAR currentEst_ = SELECTEDVALUE ( Tabla[Estancia Fábrica], total_ )
    VAR cumul_ =
        CALCULATE (
            COUNT ( Tabla[Estancia Fábrica] ),
            Tabla[Estancia Fábrica] <= currentEst_,
            ALL ( Tabla[Estancia Fábrica] )
        )
    RETURN
    DIVIDE ( cumul_, total_ )

     

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

     

2 Replies

  • Thanks AlB, this works just fine.

     

    In the future, I wish I could help others like you.


    Thanks!

  • AlB's avatar
    AlB
    Icon for Community Champion rankCommunity Champion

    Hi MTrullàs 

    It's the ALL(Tabla) that is overriding all the filters. Try this. If it doesn´t work, share the data in the same format as you did yesterday. Today's format is not good to copy

     

    NewMeasure_2 = 
    VAR total_ = CALCULATE ( COUNT ( Tabla[Estancia Fábrica] ), ALL ( Tabla[Estancia Fábrica]) )
    VAR currentEst_ = SELECTEDVALUE ( Tabla[Estancia Fábrica], total_ )
    VAR cumul_ =
        CALCULATE (
            COUNT ( Tabla[Estancia Fábrica] ),
            Tabla[Estancia Fábrica] <= currentEst_,
            ALL ( Tabla[Estancia Fábrica] )
        )
    RETURN
    DIVIDE ( cumul_, total_ )

     

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.