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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Giridhar0715
Frequent Visitor

Nested Aggr For Distinct count of customers over rolling 12 month period

Hi Guys,

 

I am struggling with a scenrio,Where i am creating a trend chart for rolling 12 month,I need to consider Distinct count of customers for last 12 months (For April 2023 i.e. May 2022-April 2023 & March 2023 i.e. April 2022-March 2023 ) and also check if the number of distinct product against those customers to be >= 2.

Kindly find below given data and output required

Giridhar0715_1-1682430892029.png

Output required (Distinct Customers(Product is >=2))

Giridhar0715_2-1682431284103.png

For Feb-23 count is 1,As only Cust ID 6 has Distinct Product Count >=2

Giridhar0715_3-1682431722150.png

 

For Dec2022 the count should be 2,As Cust ID 6&10 got Distinct Product Count >=2

Giridhar0715_0-1682432131661.png

 

Measure for distinct customer is

Running Count For 12 Months =
Var start_date = Max(TrxTable[Month])
Var MAX = Max(TrxTable[Month])
var MINI = datevalue(Month(EDATE(MAX,-11)) & "/1/" &Year(EDATE(MAX,-11)))
return

CALCULATE(DISTINCTCOUNT(TrxTable[Cust ID]),FILTER(All(TrxTable),TrxTable[TrxDate]<=MAX && TrxTable[TrxDate]>=MINI))


I am currently struggling with Distinct Customers(Product count is >=2) where i would be requireing nested aggr

 

@Ashish_Mathur 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Could you please guide how i can add one more filter,Where i want to check if the customer got Product count >=2 this year and last year.

 

Eg:For April 2023 i.e. Check if the Product count is >=2 for individual customer within May 2022-April 2023

and also for the same customer  the Product count is >=2 for May 2021-April2022

Hi,

Try this measure

Measure = if([Customer count]=BLANK(),BLANK(),COUNTROWS(FILTER(SUMMARIZE(CALCULATETABLE(VALUES(Data[Cust ID]),DATESBETWEEN('Calendar'[Date],EDATE(MIN('Calendar'[Date]),-23),MAX('Calendar'[Date]))),Data[Cust ID],"ABCD",CALCULATE([Products bought],DATESBETWEEN('Calendar'[Date],EDATE(MIN('Calendar'[Date]),-11),MAX('Calendar'[Date]))),"EFGH",CALCULATE([Products bought],DATESBETWEEN('Calendar'[Date],EDATE(MIN('Calendar'[Date]),-23),edate(MAX('Calendar'[Date]),-12)))),[ABCD]>=2&&[EFGH]>=2)))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks,Let me give a try

Thanks a lot for your time and efforts Mate!!!!It Worked 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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