Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Create a new table based on date slicer

I have a table of data (TABLE_A), which I want to group by PersonID, based on a date slicer.

 

If I selected on the date slicer 01/02/2022 to 04/03/2022, then I want to have the TABLE_OUTCOME.

 

Can someone help please?  I've tried to use SUMMARIZE, but the date filter is not affecting the output.  I'm thinking I need to use CALCULATETABLE, but can't figure it out.

 

Thanks.

 

TABLE_A  TABLE_OUTCOME
     
DatePersonID PersonIDCount
01/01/2022111 1112
01/02/2022111 2222
02/02/2022111 3331
03/03/2022222   
04/03/2022222   
04/03/2022333   
  • Hi Anonymous ,

     

    I think you need to create a separate date table and then try the following formula:

    M_ = 
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= MAX ( 'Table 2'[Date] )
                && 'Table'[Date] >= MIN ( 'Table 2'[Date] )
                && 'Table'[PersonID] = MAX ( 'Table'[PersonID] )
        )
    )
    Table 2 = CALENDAR("2022-01-01","2022-04-03")


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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

4 Replies

  • Hi,

    if this is what you want:

    you don't need any measure. You have only to add to your visual PersonID (Don't summarize) and again PersonID (Count).

    if you need a measure :

    CountPersonID = count('Table'[PersonID])
     

    If this post is useful to help you to solve your issue consider giving the post a thumbs up 

     and accepting it as a solution !

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Sorry my mistake, I should have given you the full picture.  In the end, I want to create a visualisation that shows me each group of count and how many people have that value - and this to update when you change the date filter.  So looking at the original query and based on the date filter, I have two people with 2 counts, and one person with 1 count.  Not the best example to use, but hope you can see what I am trying to achieve.  Below chart is my desired output from this exercise.

       

      I don't think the above solution would help, as I can't create a visualisation from a table visualisation.

       

       

       

       

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    Create a measure to use as a filter in the fiter pane for a table visual containing the ID field

    filter measure = COUNTROWS(VALUES(Table[ID]))

    add this measure to the filter pane for the visual and set the value to equals 1

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi Anonymous ,

     

    I think you need to create a separate date table and then try the following formula:

    M_ = 
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= MAX ( 'Table 2'[Date] )
                && 'Table'[Date] >= MIN ( 'Table 2'[Date] )
                && 'Table'[PersonID] = MAX ( 'Table'[PersonID] )
        )
    )
    Table 2 = CALENDAR("2022-01-01","2022-04-03")


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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