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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
sivarajan21
Post Prodigy
Post Prodigy

Dax function to calculate the missing dates instead of 0's and 1's

Hi,

 

Need your help on this. I have these below 2 datasets:

Points IdData DateSource
12304/01/2022Invoice
12304/02/2022Profile
12304/07/2022Invoice
123

04/08/2022

 

Profile
12304/09/2022Profile
12304/10/2022Profile
12304/11/2022Profile

 

Calendar date 
Date
01/04/2022
02/04/2022
03/04/2022
04/04/2022
05/04/2022
06/04/2022

 

The above 2 tables are to be compared. What we need to find is the missing calendar dates of points id(data table). That is, the points id '123' in Data table has missing dates 03rd april 2022 that is present in calendar table. so we need to return that missing date in a table format/summarised table. 

Expected outcome

Points IdMissing Calendar date 
12303/04/2022
12304/04/2022
12305/04/2022
12306/04/2022

 

Now  @Ashish_Mathur  helped to create a measure to find the missing dates in terms of 0's and 1's. That helped me to create a calculated column to filter 0's & 1's to find the missing dates. Below is that measure. 
Test =
1 * ( [Calendar date value] <> [Data date value] )
Above same thing can be achieved from the below measure:

Exist_In_Table2 =
CONTAINS ( 'Calendar', 'Calendar'[Date], MAX ( Data[Date] ) ) * 1
 
Both these measures returns boolean/binary values(0's&1's)
But what I want to achieve from any of these measures is to return missing dates instead of 0's & 1's,. That is finding the missing dates from one measure instead of creating two. I am confused whether this can be achieved by aggregating function/iterating function.
 

Expected outcome

Points IdMissing Calendar date 
12303/04/2022
12304/04/2022
12305/04/2022
12306/04/2022

 

Remember outcome of the measure should be dates not 0's or 1's

Please let me know if you need further info

PFA file here

 

Can you all please help me with this?

Thanks in advance @grantsamborn @lbendlin  @Arul @amitchandak @Ashish_Mathur 

1 ACCEPTED SOLUTION

you must respect the order of the columns in the tables

Screen Capture #900.png

View solution in original post

8 REPLIES 8
sizi
Helper II
Helper II

Hello all,

 

I need support in sorting this issue out. I have data where in it has multiple dates from assigned date to , planned date, actual date, approval date etc.

 

I created a date table and when i try to build a rleationship with any of the dates in the main data table, some of the records dont fetch as not all dates column have date in them.

I need a solution where in when i click date filter created from calendar table will filter the main data table to fetch the record without missing anything. If there isnt any date mentioned in the main data table, then insert date based on the primary key on the main table.

 

Below is the data for reference.  This is main data table

AssignedDatePlanned Start DateActual Start Date Task No Task NameUser
 11/21/2022 0:0010/23/2023 21:00101Testing 1A
 2/19/2023 0:00 102Testing 2B
 7/10/2023 0:007/10/2023 21:00103Testing 3C
 9/11/2023 0:009/11/2023 21:00104Testing 4D
 9/19/2023 0:009/19/2023 21:00105Testing 5E
 10/31/2023 0:00 106Testing 6F
 11/1/2023 0:0011/12/2023 21:00107Testing 7G
 1/14/2024 0:00 108Testing 8H
 1/20/2024 0:00 109Testing 9I
1/31/2023 21:002/20/2023 0:002/20/2023 21:00110Testing 10J
3/19/2023 21:008/7/2023 0:008/7/2023 21:00111Testing 11K
5/28/2023 21:00  112Testing 12L
5/28/2023 21:006/17/2023 0:006/17/2023 21:00113Testing 13M
5/28/2023 21:006/25/2023 0:006/25/2023 21:00114Testing 14N
5/28/2023 21:008/28/2023 0:008/28/2023 21:00115Testing 15O
6/7/2023 21:006/17/2023 0:009/17/2023 21:00116Testing 16P
7/16/2023 21:00  117Testing 17Q
8/14/2023 21:008/23/2023 0:008/23/2023 21:00118Testing 18R
8/21/2023 21:0010/24/2023 0:0010/10/2023 21:00119Testing 19S
8/22/2023 21:008/28/2023 0:0010/7/2023 21:00120Testing 20T
8/29/2023 21:008/29/2023 0:008/29/2023 21:00121Testing 21U
8/30/2023 21:007/2/2023 0:007/2/2023 21:00122Testing 22V
8/30/2023 21:009/9/2023 0:009/9/2023 21:00123Testing 23W
8/30/2023 21:0010/2/2023 0:0010/2/2023 21:00124Testing 24X
9/2/2023 21:009/2/2023 0:009/2/2023 21:00125Testing 25Y
9/2/2023 21:009/13/2023 0:009/13/2023 21:00126Testing 26Z

 

This is calendar table :

Calendar Date
11/21/2022 0:00
2/19/2023 0:00
7/10/2023 0:00
9/11/2023 0:00
9/19/2023 0:00
10/31/2023 0:00
11/1/2023 0:00
1/14/2024 0:00
1/20/2024 0:00
2/20/2023 0:00
8/7/2023 0:00
 
6/17/2023 0:00
6/25/2023 0:00
8/28/2023 0:00
6/17/2023 0:00
 
8/23/2023 0:00
10/24/2023 0:00
8/28/2023 0:00
8/29/2023 0:00
7/2/2023 0:00
9/9/2023 0:00
10/2/2023 0:00
9/2/2023 0:00
9/13/2023 0:00
9/30/2023 0:00
9/6/2023 0:00
10/2/2023 0:00
9/9/2023 0:00
9/16/2023 0:00
 
9/12/2023 0:00
9/16/2023 0:00
9/16/2023 0:00
9/24/2023 0:00
10/21/2023 0:00
9/30/2023 0:00
10/17/2023 0:00
 
9/20/2023 0:00
 
9/23/2023 0:00
9/26/2023 0:00
9/25/2023 0:00
9/30/2023 0:00
10/1/2023 0:00
10/3/2023 0:00
6/20/2023 0:00
10/8/2023 0:00
 
10/14/2023 0:00
10/25/2023 0:00
 
10/16/2023 0:00
10/15/2023 0:00
10/24/2023 0:00
10/28/2023 0:00
9/24/2023 0:00
11/4/2023 0:00
11/6/2023 0:00
11/14/2023 0:00
11/13/2023 0:00
11/15/2023 0:00
11/25/2023 0:00
11/28/2023 0:00

I i connect date from calendar table to assigned date, then records where assigned date is blank goes missing and if i connect planned date then it date filters data from the date present in that column which again data is missed where assigned date is blank. I want date to filter all the records to be fetched  when date is toggled and shall show records from beginning till current date data. 

Kindly give in your input.

Thanks in advance. 

 

Ahmedx
Super User
Super User

If you have multiple IDs, then you can write the measure like this
Screen Capture #893.png

Hi @Ahmedx,

 

Wow! that's a brilliant solution

You made it look so easy. Your are correct, I have multiple points id and I need your this solution but it shows some error as below I have shown the screen shot.

sivarajan21_0-1681734275115.png

 

Can you please have a look and help me to solve this error, if thats done i will accept this as solution and close this query?

Thanks in advance.

you must respect the order of the columns in the tables

Screen Capture #900.png

Hello - what do you return?

 

 

 

Screenshot_1.png

Hi @Ahmedx ,

 

Wow! this works amazingly well now. you made my day!

You not only gave me the solution but made me realize the importance of order of columns in measures. Going forward I will be careful in dealing with orders.

Didn't realise that order of columns would have this much effect on the result of dax.

 

Many thanks for your guidance and I will accept this as a solution.

 

Thank you and the community for everything

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
https://1drv.ms/u/s!AiUZ0Ws7G26Rhy_CguGTOIzoMxyJ?e=JKSmuy

Screen Capture #891.pngScreen Capture #892.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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