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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
KumarPatel80
Frequent Visitor

Power BI to find the first missing week

Hi, As a novice user, im struggling to write a query (DAX, Power Query or M query) to accomplish something here. I have three tables: Users, Calendar and Users By Week:

 

User table.png

Calendar table.png

 

 

 

 

 

 

 

UsersByWeek table.png

 

 

 

 

 

 

 

 

 

 

 

Table Relationships.png

 

 

 

 

 

 

 

 

Based on the UsersByWeek and Calendar tables,  Blue and Yellow users have missing weeks:

 

BlueMissingWeeks.png 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Green_Red-NOMissingWeeks.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

YellowMissingWeeks.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I require a new column added to USERS table to store the first missing Week #(Calendar.Index) per user.  If there is no missing week(as is Green and Red) then the first Week # is 0(zero).  This is the desired result:

 

Desired Results.png

 

 

 

 

 

 

 

Can anyone help with achieving this please?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @KumarPatel80 ,

IF you want to filter greater than 2 weeks ,  you can apply this measure to visual filter:

vxiandatmsft_0-1721900182361.png

Because measure can not applt to slicer , this method can achieve your idea.

vxiandatmsft_1-1721900229005.png

Best Regards,

Xianda Tang

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

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @KumarPatel80 ,

Below is my table1:

vxiandatmsft_0-1721891007433.png

Below is my table2:

vxiandatmsft_1-1721891028431.png

Below is my table3:

vxiandatmsft_2-1721891045804.png

You can create a measure to achieve it:

FirstMissingWeek1 = 
VAR UserWeeks = 
    CALCULATETABLE(
        VALUES('USERSBYWEEK'[WC_Date]),
        'UsersByWeek'[User] = SELECTEDVALUE(USER[User])
    )
VAR AllWeeks = VALUES('CALENDAR'[WC_Date])
VAR MissingWeeks = EXCEPT(AllWeeks, UserWeeks)
VAR FirstMissingWeek = MINX(MissingWeeks, 'CALENDAR'[Measure])
RETURN
    IF(ISBLANK(FirstMissingWeek), 0, FirstMissingWeek)
Measure = 
     SELECTEDVALUE('CALENDAR'[Index])

The final output will be like this:

vxiandatmsft_3-1721891105170.png

Best Regards,

Xianda Tang

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

Hi v-xiandat-msft,

 

That solution is perfect except is there is anyway to contain those in 

'FirstMissingWeek1' values in the USERS table?  The reason I ask is becuase I would like to introduce a slicer to to filter records by missing weeks greater than 2 for instance?  Thanks
amitchandak
Super User
Super User

@KumarPatel80 , Try measures like

 

M1 = countrows(userbyweek)

M2= Sumx(Values(User[user]), calculate( countx(Values(calendar[Week Year]), if(isblank([M1]), [Week Year], blank())) ))

 

very similar to

Power BI Items/Categories not sold to the customers: https://youtu.be/AbuKvAnicwo

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for your reply.  

Anonymous
Not applicable

Hi @KumarPatel80 ,

IF you want to filter greater than 2 weeks ,  you can apply this measure to visual filter:

vxiandatmsft_0-1721900182361.png

Because measure can not applt to slicer , this method can achieve your idea.

vxiandatmsft_1-1721900229005.png

Best Regards,

Xianda Tang

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

Thanks for the response.  Thats why I was hoping for the value to be in a column in the Users table.  Is this achievable so that I can use a Slicer visual?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.