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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Junaid11
Helper V
Helper V

Count of instances of ID occurrence

Hello,

I have a strange count requirments requirements. I want to count ID occurence for each day if ID rpeat next day it should not be counted. The outcome should be based on below attached picture.

DEMO (1).PNG

It would be quite helpfulif I get it solved.

Thank you

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

Hi @Junaid11 ,

 

Please create below measures:

Flag = CALCULATE(MAX('Table'[AccountID]),FILTER(ALL('Table'), [AccountID]=MAX('Table'[AccountID])&& [Date]=MAX('Table'[Date])-1))
Count = COUNTROWS(FILTER('Table',[Flag]=BLANK()))
Combine = 
var _t=SUMMARIZE(FILTER('Table',[Date]=MAX('Table'[Date]) && [Flag]=BLANK()),[AccountID])
return CONCATENATEX(_t,[AccountID],",",[AccountID],ASC)

Output:

Eyelyn9_0-1644914672783.png


Best Regards,
Eyelyn Qin
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

6 REPLIES 6
v-eqin-msft
Community Support
Community Support

Hi @Junaid11 ,

 

Please create below measures:

Flag = CALCULATE(MAX('Table'[AccountID]),FILTER(ALL('Table'), [AccountID]=MAX('Table'[AccountID])&& [Date]=MAX('Table'[Date])-1))
Count = COUNTROWS(FILTER('Table',[Flag]=BLANK()))
Combine = 
var _t=SUMMARIZE(FILTER('Table',[Date]=MAX('Table'[Date]) && [Flag]=BLANK()),[AccountID])
return CONCATENATEX(_t,[AccountID],",",[AccountID],ASC)

Output:

Eyelyn9_0-1644914672783.png


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

David-Ganor
Resolver II
Resolver II

Hi @Junaid11 

Please add a calcualted colum which deterines if it should be counted as followes:

 

CountValue=

VAR this_row_account=Table[AccountID]

VAR this_row_date=Table[Date]

VAR Account_Present_Yesterday=

CALCULATE(COUNTROWS(Table),

FILTER(Table

,Table[AccountID]=this_row_account && Table[Date]=this_row_date-1)

 

RETURN

IF(Account_Present_Yesterday>0,Blank(),Table[AccountID])

 

Then - on the visual - count CountValue column.

 

Hope it helps,

 

David Ganor

Hello @David-Ganor ,

This is what it shows and when I made it count then the below result came.

dfsdfsdfsdfsdf.PNGffdfdfdfdfdf.PNG

@Junaid11 please remove the account id column from the visual.

Hello @David-Ganor ,

Yeah it is working for the count but can't we get the concatenation as (A,B,C,D,E) as mentioned?

@Junaid11  I'm not sure really...

Please try to make a measure using 

CONCATENATEX

Something like this:

CONCATENATEX (
            CALCULATETABLE ( VALUES ( 'Table'[Count Value] ) ),
            Table[Count Value],
            ", ",            -- Separator (optional)
            Table[Count Value],  -- Sorting expression (optional)
            ASC              -- Sorting direction (optional)
        )

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.