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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

DISTINCTCOUNT AT WEEK LEVEL

Hi! I hope you are well. I was developing a Power BI measure and I found a problem:
I want to see variation of clients that enter to an app per week.

I have a table like these in which "Alta_Pedido_Dt" is the date in which the client entered the app, "Cliente" is the unique identifier of that client.

TomasB_0-1693189309246.png

 

What I expect is this:
The first two registers correspond to the first week and the same client, the other rows correspond to this week (7 different clients). I want to create a measure that does: 
Measure = Quantity of different clients that entered the app this week(7) / Quantity of different clients that entered the last week(1) -1 = 6

 

I ve developed the next measures:
Q_USERS = DISTINCTCOUNT(TABLE1[Cliente])

 

USERS_VARIATION_PER_WEEK =
VAR _ACTUAL_WEEK = CALCULATE(SUMX(TABLE1,[Q_USERS]),FILTER(Calendar,Calendar[WEEK] = WEEKNUM(max(TABLE1[Alta_Pedido_Dt]),1)))

VAR _LAST_WEEK = CALCULATE(SUMX(TABLE1,[Q_USERS]),FILTER(Calendar,Calendar[WEEK] = (WEEKNUM(max(TABLE1[Alta_Pedido_Dt]),1)-1)))

RETURN
ROUND(DIVIDE(_ACTUAL_WEEK,_LAST_WEEK)-1,1)

 

But ive got an unsatisfying result:

TomasB_1-1693189663943.png

The value of the measure Q_USERS that i ve created is right for the week 33 and 34. But MEASURE_CREATED(USERS_VARIATION_PER_WEEK) is 3.5, why? There´s something that i am missing.

 

I wait for your help. Thank u so much!




1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , In the table use the Week from Date table, also Change measures like

and use the week rank as given below

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , In the table use the Week from Date table, also Change measures like

and use the week rank as given below

 

Have these new columns in Date Table, Week Rank is Important in Date/Week Table

Week Rank = RANKX('Date','Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX('Date','Date'[Year Week],,ASC,Dense) //YYYYWW format


These measures can help
This Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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