Forum Discussion

riglesiassanz's avatar
riglesiassanz
Regular Visitor
3 years ago
Solved

COUNT SELECTED MONTHS WITH CONDITIONAL

Hello,
Anyone could please help me with this case?

I've trying a solution but I couldn't find a good author.

 

I've simplified the model: 

Thanks!!

  • Mikelytics's avatar
    Mikelytics
    3 years ago

    Hi riglesiassanz ,

     

    I am not sure if I get what you mean. 🙂

     

    Lets say the measure you use is your base measure. Can you try to put your base measure in my mesure in the following area? 

     

     

    In the end it should look like this or similar:

    DISTINCT 1 EACH PERIOD = 
    
    SUMX(
       VALUES(FactSampleTable[CODTDA]),
       
       var var_PeriodsInScope = DISTINCTCOUNT(DimDate[Year-Month])
       var var_MonthsCovered =
                        SUMX(
                           VALUES(DimDate[Year-Month]),
                           CALCULATE([Tiendas SC])
                        )
       RETURN
       IF(var_PeriodsInScope=var_MonthsCovered,1,0)
    )

     

    The please put my Measure in the matrix.

     

    Best regards

    Michael

    -----------------------------------------------------

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!

    @ me in replies or I'll lose your thread.

     

     

7 Replies

    • riglesiassanz's avatar
      riglesiassanz
      Regular Visitor

      Hi mangaus1111 I think this could help. It is written in Spanish, but It the end is east to understand. I Hope! 

      •  
      • Mikelytics's avatar
        Mikelytics
        Icon for Resident Rockstar rankResident Rockstar

        Hi riglesiassanz ,

         

        I recreated your example with the followiung dataset. 

         

        Fact Table:

         

         

        Date Dimension Table with a year-Month Column:

         

        Data Model:

         

        Measure and Result:

         

        Measure:

         

        DISTINCT 1 EACH PERIOD = 
        
        SUMX(
           VALUES(FactSampleTable[CODTDA]),
           
           var var_PeriodsInScope = DISTINCTCOUNT(DimDate[Year-Month])
           var var_MonthsCovered =
                            SUMX(
                               VALUES(DimDate[Year-Month]),
                               CALCULATE(DISTINCTCOUNT(FactSampleTable[CODTDA]))
                            )
           RETURN
           IF(var_PeriodsInScope=var_MonthsCovered,1,0)
        )

         

         

        Best regards

        Michael

        -----------------------------------------------------

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!

        @ me in replies or I'll lose your thread.

         

         

         

         

         

         

  • Mikelytics's avatar
    Mikelytics
    Icon for Resident Rockstar rankResident Rockstar

    riglesiassanz  Awesome! 🙂 Thakn you for your feedback!

     

    Best regards

    Michael

    -----------------------------------------------------

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your thumbs up!

    @ me in replies or I'll lose your thread.