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
JulienFinalcad
New Member

sum on the last 12 months of the number of distinct user I have by month

Hello,

 

I need to calculate the sum on the last 12 months of the number of distinct user I have by month. (I can't just do a DISTINCTCOUNT on the last 12 month as I can have the same user_id on multiple month)

 

I made a first summarize to have the number of distinct users by month : SUMX(SUMMARIZE(activities;activities[user_id];dim_time[year_month];"NB User";DISTINCTCOUNT(activities[user_id]));[NB User])

 

This formula is working fine and now I need to sum the result on the last 12 month. 

 

I try a formula like : 12M_Users = CALCULATE(SUMX(SUMMARIZE(activities;activities[user_id];dim_time[year_month];"NB User";DISTINCTCOUNT(activities[user_id]));[NB User]);DATEADD(dim_time[date];-12;MONTH))

 

But I have an error message :

 erreur.JPG

1 ACCEPTED SOLUTION

@quentin_vigne : I solve my problem with this new formula : 

12M_Users = CALCULATE(SUMX(SUMMARIZE(activities;dim_time[year_month];"NB User";DISTINCTCOUNT(activities[user_id]));[NB User]);DATESBETWEEN (dim_time[date];NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( dim_time[date] ) ) );LASTDATE ( dim_time[date] )))

 

I made a mistake in my first summarize.

 

Thanks for your help 🙂

View solution in original post

6 REPLIES 6
quentin_vigne
Solution Sage
Solution Sage

Hi @JulienFinalcad

 

Your error message come from the relationship between two of your tables, you need to edit this relationship to one direction only.

 

 

- Quentin

@quentin_vigne : I understand the message but my relationnship between my two tables activities and dim_time is only one direction.

 

relations.JPG

@JulienFinalcad

 

Do you have any other table that are related via a bi directionnal filtering ? Not sure that will solve the problem but you can still try

 

- Quentin

No I don't have any bi directional filtering in my current model.

 

All my other dax calculation are working fine. Only this one is not working. Perhaps I made some error. I just want to have a cumulative sum on last 12 month of a distinct count by month 😉

 

value.JPG

@JulienFinalcad

 

Can you provide a sample of data ? I will try to do it on my computer

 

 

- Quentin

@quentin_vigne : I solve my problem with this new formula : 

12M_Users = CALCULATE(SUMX(SUMMARIZE(activities;dim_time[year_month];"NB User";DISTINCTCOUNT(activities[user_id]));[NB User]);DATESBETWEEN (dim_time[date];NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( dim_time[date] ) ) );LASTDATE ( dim_time[date] )))

 

I made a mistake in my first summarize.

 

Thanks for your help 🙂

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.

Top Solution Authors