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
Anonymous
Not applicable

DAX Trouble with count and Max Date

Hi Everyone!

 

I'm having any difficult with a measure that I need to create.

My scenario is as follow:

 

TABLE1

usu_id_iname_nv
60006Petronila
60027OSCAR
60029Sandra
60030María
60031Carlos
60034Rocio

 

TABLE2

idusu_id_ige_categoria_idfecha_inicio
160006130/08/2016
9812160027130/09/2016
9815860029111/11/2016
9816060030117/11/2016
9816160031118/11/2016
9816260034118/11/2016
9816560006218/11/2016
9816652118/11/2016
9816960030218/11/2016
9817060006121/11/2016
12613223120/02/2017
1261338078220/02/2017
12613460031220/02/2017

 

 

I need a measure that count the actual number of clients by category. As you can see the clients can change between categories do I need to group the client in the most recent category. In this case:

ge_categoria_idClients
14
22



Anyone can help me?
Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Finally I found a solution.


I have created a column calculated in TABLE1 with the current category of the client.
It was easier than I expected.


Thanks for your collaboration.

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can try to use below sample if it suitable for your requirement.

 

Steps:

1. Filter the not contains records.

Filtered Table = FILTER(Sheet1,CONTAINS(Sheet2,[usu_id_i],[usu_id_i]))

 

2. Add a calculated column to analysis the count of date range based on 'category id' group:

Count = 
var compare_range = 1
return
COUNTX(FILTER('Filtered Table',[ge_categoria_id]=EARLIER([ge_categoria_id])&&[fecha_inicio]>=EARLIER([fecha_inicio])-compare_range&&[fecha_inicio]<=EARLIER([fecha_inicio])+compare_range),[fecha_inicio])

 7.PNG

 

 

 3. Summary these records.

Result = SUMMARIZE('Filtered Table',[ge_categoria_id],"Clients",MAX('Filtered Table'[Count]))

 

 9.PNG

 

Notice: you can modify the variable 'compare_range' to switch the compare range. Step 1 is an option, you can skip it if you need.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Thanks @v-shex-msft for the answer but I have tried and It didn't work.
The result of the calculations is wrong.

 

And I would rather use a measure.

Hi @Anonymous,

 

>>The result of the calculations is wrong.

Can you share some detail information about these?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Finally I found a solution.


I have created a column calculated in TABLE1 with the current category of the client.
It was easier than I expected.


Thanks for your collaboration.

Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi, what happen with users 52,23,8078 do you want to count them too

 

Because including it the result will be 6 & 3.

 

Victor

Lima - Peru




Lima - Peru
Anonymous
Not applicable

Hi @Vvelarde,

Users 52, 23 and 8078 are not included because they aren't in my TABLE1.

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.