Forum Discussion

MinnieMouse's avatar
MinnieMouse
New Member
3 years ago

Help with dax formula

Hello! I need to add a "distinctcount" for the session_id in this formula, but I have no luck with it. Is it even possible? Or would I better create a measure instead of a table?


Basically I need to find out how many distinct sessions have 2 or more rows (views) from the "Table_views". 

the formula I've used for the table is: 


2nd screen view=

       Var_Table=
         SUMMARIZE(

                 'Table_views'

                 'Table_views'[session_id],
                  "_Count",COUNTROWS('Table_views')

                  )

        RETURN

      COUNTROWS(FILTER(_Table,[_Count] >=2)) 

3 Replies

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

    Hi MinnieMouse ,

     

    You could try below code:-

    Var_Table =
    FILTER (
        SUMMARIZE (
            'Table_views',
            'Table_views'[session_id],
            "_Count",
                COUNTROWS (
                    FILTER (
                        'Table_views',
                        'Table_views'[session_id] = EARLIER ( 'Table_views'[session_id] )
                    )
                )
        ),
        [_Count] >= 2
    )
    • MinnieMouse's avatar
      MinnieMouse
      New Member

      Thank you for your time! That generates exactly the same output as the formula i've used. I suppose these are distinct session_id as nothing happens when I filter it in the visual! Thanks again! 

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

        MinnieMouse , It would be very helpful to answer if you could share the sample data(not in a screenshot) with expected output.