Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Apply conditionals OR & AND for two segmentations

Hello,

I need two apply two date segmentations in my report but I would like to be able to choose between apply Date1 AND Date2 or apply Date1 OR Date2.

For example, if I have the following table:

MARKETDate1Date2
Germany2020-072021-08
Germany2020-072021-09
Germany2020-082021-10
Germany2020-082021-11

 

And I filter by Date1 = 2020-07 AND Date2 = 2021-08, I will get:

MARKETDate1Date2
Germany2020-072021-08

 

But if I filter by Date1= 2020-07 OR Date2= 2021-10, I should get:

MARKETDate1Date2
Germany2020-072021-08
Germany2020-072021-09
Germany2020-082021-10

 

How can I apply the OR filter?

Thank you in advance!

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for the approches, but unfortunately none of those are working for me. I don't understand why.

    Here is the result I get for different options:

    EitherCondition = 
    VAR s1 = CONCATENATEX('ANHO_MES_ENTRADA DESCONECTADA'; [ANHO_MES_ENTRADA].[Date]; ";") 
    VAR s2 = CONCATENATEX('ANHO_MES_SALIDA DESCONECTADA'; [ANHO_MES_SALIDA].[Date]; ";") 
    RETURN IF( SEARCH(MAX(entrada_salida_tienda_ES_US_FR_GB_SF[ANHO_MES_ENTRADA]); s1; 1; 0) > 1 
    || SEARCH(MAX(entrada_salida_tienda_ES_US_FR_GB_SF[ANHO_MES_SALIDA]); s2; 1; 0) > 0; 
    1; 
    0)
    EitherCondition2 = 
    VAR MatchesEntrada =
        CALCULATE (
            COUNTROWS ( 'entrada_salida_tienda_ES_US_FR_GB_SF' );
            KEEPFILTERS ( TREATAS ( VALUES ( 'ANHO_MES_ENTRADA DESCONECTADA'[ANHO_MES_ENTRADA] ); ANHO_MES_ENTRADA[ANHO_MES_ENTRADA].[Date] ) )
    ) > 0
    VAR MatchesSalida =
        CALCULATE (
            COUNTROWS ( entrada_salida_tienda_ES_US_FR_GB_SF );
            KEEPFILTERS ( TREATAS ( VALUES ( 'ANHO_MES_SALIDA DESCONECTADA'[ANHO_MES_SALIDA]); ANHO_MES_SALIDA[ANHO_MES_SALIDA].[Date] ) )
        ) > 0
    RETURN
      MatchesEntrada || MatchesSalida

     

     

    I used the disconnected (ANHO_MES_ENTRADA DESCONECTADA and ANHO_MES_SALIDA DESCONECTADA) tables in the slicers and the connected ones for the visualization (ANHO_MES_ENTRADA and ANHO_MES_SALIDA). The main table is 'entrada_salida_tienda_ES_US_FR_GB_SF'. Do you know what could be the problem?
    Thank you!

    • AlexisOlson's avatar
      AlexisOlson
      Icon for Super User rankSuper User

      Your second one looks reasonable to me.

       

      As to why the Entrada 2020-08 and Salida 2020-07 row returns false, I'm not sure unless there aren't any rows in your main table with Entrada = 2020-08.

      • Anonymous's avatar
        Anonymous
        Not applicable

        You are right, the second one is fine and returns false because in the main table there is no Entrada=2020-08 when Salida = 2020-07. Thank you very much for your help!