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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ginalu
Helper I
Helper I

Issue with Missing data in Calculation

Some lessons are included while others are missing in the calculation. 

Example of Missing Lesson in Calculation

For example, a user conducted a lesson on 10/16. Since today is 10/21, the lesson should be counted as an activity within the last seven days. However, it is not being included in the calculation as expected.

 

The formula and data are as shown in the image below:

 

Recent7DaysActiveUsers =
CALCULATE(
    DISTINCTCOUNT(USERUNQ[user_id]),
    FILTER(
        LESSONN,
        TRUNC(LESSONN[start_time]) >= TODAY() - 7 &&
        TRUNC(LESSONN[start_time]) < TODAY() &&
        USERUNQ[user_id] = LESSONN[teacher_id]
    )
)
9 REPLIES 9
Anonymous
Not applicable

Hi,@ginalu .I am glad to help you.

Has your problem been solved?
If you have found suitable solutions, please share them as it will help more users with similar problems.
Or you can mark the valid suggestions provided by other users as solutions.
Thank you very much for your understanding and support of Power BI.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

Anonymous
Not applicable

Hi,MNedix, sanalytics and Kedar_Pande .

thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.
Hello,@ginalu .I am glad to help you.

Here is my test.

I noticed that you have a one-to-many relationship between your two tables, try using the RELATED function in the filter function on a field in the other table

like this.

Calculate the number of users who have been active in the last seven days.

Recent7DaysActiveUsers = 
CALCULATE(
    DISTINCTCOUNT(USERUNQ[user_id]),
    FILTER(
        LESSONN,
        TRUNC(LESSONN[start_time]) >= TODAY() - 7 &&
        TRUNC(LESSONN[start_time]) < TODAY() &&
        RELATED(USERUNQ[user_id]) = LESSONN[teacher_id]
    )
)



vjtianmsft_0-1730278811006.png

 

vjtianmsft_1-1730278819022.png

Below is my test data:

vjtianmsft_2-1730278880282.png

 

vjtianmsft_3-1730278888710.png

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

sanalytics
Super User
Super User

Hello @ginalu 
You can use below DAX

 

Recent7DaysActiveUsers =
CALCULATE (
DISTINCTCOUNT ( USERUNQ[user_id] ),
FILTER (
Summarize(
LESSONN,LESSONN[start_time],LESSONN[teacher_id]
),
TRUNC ( LESSONN[start_time] )
>= TODAY () - 7
&& TRUNC ( LESSONN[start_time] ) < TODAY ()
),
USERUNQ[user_id] = LESSONN[teacher_id]
)

 

instead of filtering whole table, you can summarize the table with required columns.

 

Regards

sanalytics

 

Hi @sanalytics 

Thank you for your reply. I tried it, but an error message appeared:

The expression includes columns from multiple tables, but only columns from a single table can be used in a True/False expression for table filtering.

Kedar_Pande
Super User
Super User

@ginalu 

You can try the updated DAX:

Recent7DaysActiveUsers =
CALCULATE (
DISTINCTCOUNT ( USERUNQ[user_id] ),
FILTER (
LESSONN,
TRUNC ( LESSONN[start_time] )
>= TODAY () - 7
&& TRUNC ( LESSONN[start_time] ) < TODAY ()
),
USERUNQ[user_id] = LESSONN[teacher_id]
)

Ensure that start_time in LESSONN is in a date format

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

 

Hi @Kedar_Pande ,

 

Thank you for your reply. I tried it, but an error message appeared:

The expression includes columns from multiple tables, but only columns from a single table can be used in a True/False expression for table filtering.
Snipaste_2024-10-21_17-08-28.png

 

MNedix
Super User
Super User

Heya,

I think TRUNC throws a spanner in the works. Could you please try DATEVALUE instead? Also, I don't know your data but are you sure about the last filter argument?



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Hi @MNedix 

Thank you for your reply. I tried it, but it still missing in the calculation.Snipaste_2024-10-21_17-11-03.pngSnipaste_2024-10-21_17-11-21.pngSnipaste_2024-10-21_17-12-53.png

Hi,

Could you please split in Power Query the start_time column by delimiter? Try to isolate only the date portion of that column, I remember it helped me in the past. Then adjust the calculation accordingly.

MNedix_0-1729580548482.png

 



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.