Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
misiek5510
Helper III
Helper III

Counting Reoccurrences, New and Completed Entries based on month

Hi All,

 

I'm using data as per example table below:

dateuserregioncontract
01/01/2021bob@gmail.comnorthkfc
01/01/2021steve@gmail.comnorthkfc
01/02/2021bob@gmail.comnorthkfc
01/02/2021john@gmail.comsouthkfc
01/02/2021arnold@gmail.comsouthnasa
01/03/2021bob@gmail.comnorth

kfc

 

This is an example extract from a reporting tool which shows users that have an outstanding action against them. Using the example above bob@gmail.com from north had an action against him in January as well as Stave, however in February Steve has completed the action as his name is gone, however bob's name is still there along with two new ones (john and Arnold), this would tell us that in February we had 1 completion (Steve), 1 reoccurring entry (bob) and two new entries (John & Arnold). March would show two completions and 1 reoccurring entry (bob). 

 

As this will be viewed by everyone within our organisation I cannot display the emails address, I would have to use nick name e.g. user1,user2 etc or just using regions and months as summary. e.g.

 

February:

Comleted:1

Not Completed:1

New:2 

 

This is the code I'm trying at the moment to see what are the reoccurring entries: 

 

reoccurring times = countx(SUMMARIZE(DATACOMP,DATACOMP[Month Year],DATACOMP[User ]),DATACOMP[User ])

 

However it just adds the months together instead of counting just the reoccurring ones.  No clue what it would be for new entries either 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @misiek5510 

 

Result:

vangzhengmsft_0-1639121409005.pngTry to create measures as below:

 

New:

New = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)
VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)
VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _New

Not Completed:

NOT Completed = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)

VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)
VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _Rep

 

Count (3):

_count_Completed = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)

VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)

VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _Completed
_count_New = 
VAR _ADD_T=ADDCOLUMNS('Table',"_NEW",[New],"_NotCompleted",[NOT Completed])

return SUMX(_ADD_T,[_NEW])
_count_NotCompleted = 
VAR _ADD_T=ADDCOLUMNS('Table',"_NEW",[New],"_NotCompleted",[NOT Completed])

return SUMX(_ADD_T,[_NotCompleted])

 

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

View solution in original post

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @misiek5510 


Glad to be helpful to you.

 

Yes, it will show him as new.

The new measure will be similar to the following, I think

NOT COMPLETED DUE TO STATUS =
IF (
    [Not completed] > 0,
    IF (
        MAX ( user ) IN VALUES ( 'Status'[name] ),
        "NOT COMPLETED DUE TO STATUS",
        "NOT Completed"
    )
)

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

v-angzheng-msft
Community Support
Community Support

Hi, @misiek5510 

 

Result:

vangzhengmsft_0-1639121409005.pngTry to create measures as below:

 

New:

New = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)
VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)
VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _New

Not Completed:

NOT Completed = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)

VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)
VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _Rep

 

Count (3):

_count_Completed = 
VAR _PRE_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),-1))
VAR _PRE_list=SUMMARIZE(_PRE_T,[user])

VAR _Current_T=FILTER(ALL('Table'),EOMONTH('Table'[date],0)=EOMONTH(MAX('Table'[date]),0))
VAR _Current_list=SUMMARIZE(_Current_T,[user])

VAR _COUNT_PRE_user=if(COUNTROWS(_PRE_list)=BLANK(),0,COUNTROWS(_PRE_list))
VAR _COUNT_CRU_user=if(COUNTROWS(_Current_list)=BLANK(),0,COUNTROWS(_Current_list))

VAR _This_user=MAX('Table'[user])

VAR _New=IF(
    NOT(_This_user IN _PRE_list)&&_This_user IN _Current_list,1,0)

VAR _Rep=IF(
    _This_user IN _PRE_list&&_This_user IN _Current_list,1,0)

VAR _Completed=Countrows(EXCEPT(_PRE_list,_Current_list))

return _Completed
_count_New = 
VAR _ADD_T=ADDCOLUMNS('Table',"_NEW",[New],"_NotCompleted",[NOT Completed])

return SUMX(_ADD_T,[_NEW])
_count_NotCompleted = 
VAR _ADD_T=ADDCOLUMNS('Table',"_NEW",[New],"_NotCompleted",[NOT Completed])

return SUMX(_ADD_T,[_NotCompleted])

 

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

This worked amazingly thank you very much!

Just got a last quick question: If user appears again in the table in a year or two will it show him as new?
Also, I have a list of blacklisted users in a second table "Status", so I'm looking to add NOT COMPLETED DUE TO STATUS measure so if a user exist in table status then its "NOT COMPLETED DUE TO STATUS" and if not its "NOT Completed". 

misiek5510
Helper III
Helper III

Also is there a way to too add an dynamic unique ID for the same enties in a column?
For example 

nameid
john1
steve2
bob3
john1

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.