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
Delmekka
Frequent Visitor

Distinct Count on ID between periods

Hi there, 

 

So glad i joined this community and prior of everything, thanks for the helping hand 🙂 

I have this specific question, which in my mind sound like and "IF" situation.

 

I'm managing a team of Reps, they visit companies from Monday to Friday. 

I'd like to do a distinct count on a weekly basis on the Companies ID. 

 

For example : 

When a rep visits a company that has not been seen more than 1 time this week, the value of the contact is equal 1. 

On the other hand, when a rep is visiting a same company during one week, it's equal : 1/(number of visit), if it's 2 visits it's equal 0,5 and so on. 

 

The tricky situation i am in is defining in the measure in terms of Time Intelligence. 

Right now, my guess would go with an IF measure and a DistinctCount but i'm not so good in DAX :'(. 

 

If you have any tips for me that would be much appreciated 🙂 

Thanks a lot, have a nice summer and stay safe 

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Delmekka ,

I created some data:

vyangliumsft_0-1655101169247.png

Here are the steps you can follow:

1. Create measure.

solve1_measure =
var _count=
COUNTX(
    FILTER(ALL('Table'),'Table'[Weeknum]=MAX('Table'[Weeknum])&& NOT('Table'[Week]) in {6,7}&&'Table'[visits]="Yes"),[Date])
return
IF(
    _count >1,1,0)
solve2_measure =
var _count=
COUNTX(FILTER(ALL('Table'),'Table'[Weeknum]=MAX('Table'[Weeknum])&&NOT( 'Table'[Week]) in {6,7}&&'Table'[company]=MAX('Table'[company])&&
'Table'[visits]="YES"),[Date])
return
DIVIDE(1,_count)

2. Result:

vyangliumsft_1-1655101169250.png

If I have misunderstood your meaning, please provide your desired output.

 

Best Regards,

Liu Yang

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

Hi there, 

 

Thanks for the answer and to be honest it kinda helped me understanding the situation i am in. 

First of all, since i'm working on CRM data, every line i have is equal to a visit so i don't have a use of boolean type of data like the YES/NO visit. 

 

Your method for the 2 solve proposition is actually quite what i'm looking for. 

But in this situation where i used your answer, i only get one result which is 1.

 

Here you can see my structure, 

I'm counting the number of IDs (Account_vod_c) on a weekly basis. 

So this better be a CountX based on the 1st and last day of the week, and on the same week (So WeekNum and Weekday are good for this).

 

My only concern is that i keep getting the same value over and over.

Thanks a lot for the help

 

Driss

Screen_PBI1.jpgScreen_PBI2.jpg

 

@v-yangliu-msft 

@amitchandak 

@Ashish_Mathur 

@SpartaBI 

 

If anyone could help me please that would be so much appreciated 🙂 

Thanks a lot

 

Hi,

Share some data and show the expected result.  If you share the download link of your file, then create a Calendar Table and ensure you have a Weekday/Weeknum column there.


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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

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.