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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Need help on calculation

Hi there, i need some help with a calculation . i have two tables below.   Table1 with 'user' column.  i have total 8 users. this number may change every day.

                                          Table2 with 'message_id', 'user',  'date'  columns.

 

I want to find 'number of users with no message_id's  on  particular date..For example. on 04/27/2019 only 'john' has 1 messgae_id.  so the result should be (total users - users with messages) 8-1 = 7.

I want to show this for each date between min(date) and max(date).

 

 date                    no of users with no messages

4/27                          7  

4/28                          0

4/29                          2

4/30                          0                     

5/1                            1     

5/2                            0

5/3                            1

5/4                            2

 

 

Table1

user

john
sam
tom
kane
joe
chris
pete
mike

 

Table2

message

_ID            user       date

46yughjohn04/27/2019
ft667john04/29/2019
66ugjohn05/03/2019
f768sam04/29/2019
877gghsam05/04/2019
45fggtom05/01/2019
788hjjtom05/04/2019
1 ACCEPTED SOLUTION

Hi @Anonymous ,

Actually, we can use SUM() or MAX() or other Aggregate function in this scenario, in "message[date] =" the = operator can only accept a scalar rather than a column "'Table'[date]", as a result, we need to use a Aggregate function to change the column to a value.

But don't be worried about this, actually, in this scenario, only one value in the column "'Table'[date]" becuase it has been filtered by the table visual, as a result, SUM(), MIN(), MAX() can get the same result.

Best Regards,

Teige

View solution in original post

6 REPLIES 6
TeigeGao
Solution Sage
Solution Sage

Hi @Anonymous ,

In your scenario, we can first create a table with the date:

Table = VALUES(message[date])

Then create a measure like below: 

Measure = COUNT(user[user]) - CALCULATE(DISTINCTCOUNT(message[user]),FILTER(ALL(message),message[date] = MIN('Table'[date])))

The result will like below:

PBIDesktop_LU5BVTkiPq.png

Best Regards,

Teige

Anonymous
Not applicable

thanks for reply.....@TeigeGao in the Measure expression, . why did u use 'MIN('Table'[date]'...  im not able to undertsand 

Hi @Anonymous ,

Actually, we can use SUM() or MAX() or other Aggregate function in this scenario, in "message[date] =" the = operator can only accept a scalar rather than a column "'Table'[date]", as a result, we need to use a Aggregate function to change the column to a value.

But don't be worried about this, actually, in this scenario, only one value in the column "'Table'[date]" becuase it has been filtered by the table visual, as a result, SUM(), MIN(), MAX() can get the same result.

Best Regards,

Teige

Anonymous
Not applicable

@TeigeGao thx for the explanation

Cmcmahan
Resident Rockstar
Resident Rockstar

Do you have some way of tracking when users enter the system?

 

Because if later you have 1000 users, if you do the calculation for today, you'll have 999 users that didn't message on 4/27/2019.

 

Anonymous
Not applicable

@Cmcmahan  right now idont have....but we can add a date field, so we know how many users we have each day.

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.