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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PBI_Monkey
Helper I
Helper I

Get 1 Date per code in table

Hi all,

 

I have a table with the following columns:

Code Date        Time         code isdefault
A 28/03/2023 0700-2100 N FALSE
A 28/03/2023 0700-2100 T TRUE
A 29/03/2023 0700-2100 N FALSE
A 29/03/2023 0700-2100 T TRUE
A 30/03/2023 0700-2100 N FALSE
A 30/03/2023 0700-2100 T TRUE
A 31/03/2023 0700-2100 N FALSE
A 31/03/2023 0700-2100 T TRUE
A 1/04/2023 0700-2100 T TRUE
A 2/04/2023 0700-2100 T TRUE
A 3/04/2023 0700-2100 T TRUE
A 4/04/2023 0700-2100 T TRUE
A 5/04/2023 0700-2100 T TRUE

 

You can see that some dates are the same with a different value for code (N/T) and different value for isdefault (True/False)

 

I'd like to show the table like this, but struggling to create a measure/column to create this:

Code Date Time code         isdefault
A 28/03/2023 0700-2100 N FALSE
A 29/03/2023 0700-2100 N FALSE
A 30/03/2023 0700-2100 N FALSE
A 31/03/2023 0700-2100 N FALSE
A 1/04/2023 0700-2100 T TRUE
A 2/04/2023 0700-2100 T TRUE
A 3/04/2023 0700-2100 T TRUE
A 4/04/2023 0700-2100 T TRUE
A 5/04/2023 0700-2100 T TRUE

 

The resulting table should always show the row when 'isdefault' = FALSE & 2 rows with same date

or if is there is only 1 unique date per row and isdefault = TRUE

 

Any ideas would be great 🙂

 

Thank you

1 ACCEPTED SOLUTION

8 REPLIES 8
Ahmedx
Super User
Super User

watch my video
https://1drv.ms/v/s!AiUZ0Ws7G26RhmqC8FHuvTvRNzs7?e=4Pp6TN
Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26RhmkCXBXRqesgOkU5?e=LGOEaB

= Table.Group(#"Changed Type", {"DateTime"}, {{"Count", 
each Table.FirstN(_,1)
}})

Hi @Ahmedx ,

 

Thanks for the cool reply.

I tried your solution but it doesn't work. Seems to be excluding alot of data.

I basically have 2 subsets of data (2 queries which I append into 1) - See screenshot

PBI_Issue.PNG

The resulting table must have all data from Table 1 and not matching rows from the 2nd Table.

So from table 2 in this example, I want to show the rows from 1st April to 5th April.

Business   Date               Time           Code     isdefault
A                28/03/2023 0700-2100  N          FALSE
A                29/03/2023 0700-2100  N          FALSE
A                30/03/2023 0700-2100  N          FALSE
A                31/03/2023 0700-2100  N          FALSE
A                1/04/2023 0700-2100     T          TRUE
A                2/04/2023 0700-2100     T          TRUE
A                3/04/2023 0700-2100     T          TRUE
A                4/04/2023 0700-2100     T          TRUE
A                5/04/2023 0700-2100     T          TRUE

 

Thanks

If I understand you correctly, then you first need to do
1) Right Anti Join (table1,table2)
2) combine what you got with 1 table
---------

I can't do this without a real example.
read this:
https://gorilla.bi/power-query/join-types/

Hi @Ahmedx ,

 

 

I tried the anti join and then appended the result with Table 1.

I get strange results:

PBI_Monkey_0-1680413195451.png

I've attached the .PBIX 

https://www.dropbox.com/s/pvqgf5jn616249i/WR.pbix?dl=0 

Thanks

Thank you @Ahmedx. Seems I have to include 3 fields to join in the right-anti join.

Thanks, your solution worked.

KeyurPatel14
Responsive Resident
Responsive Resident

Hi @PBI_Monkey ,

can you please use Power Query and Remove duplicates from the Date Column?
Try this and let me know if you have any queries.

Thanks for the reply @KeyurPatel14 

Removing duplicates won't work as there is a code which is different on the row with the same date

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors