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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tez
Resolver I
Resolver I

Date parameter for DAX table comparison

Hi!

I have to create a table comparison within Power BI. Here´s demo data for better understanding. I have one table which consists of a number of IDs for some timestamps:

Table.png

I have to create a comparison for two timestamps, which shows, which IDs are recorded on one timestamp but not the other, and which IDs are recorded on both timestamps. For this I have created a calculated column which allows to filter:

 

 

Intersection = 
    VAR Date1 = DATE(2020,4,1)
    VAR Date2 = DATE(2020,5,3)
    VAR Table1 = FILTER(TestTable, [Date]=Date1)
    VAR Table2 = FILTER(TestTable, [Date]=Date2)
return IF(AND([Date]<>Date1,[Date]<>Date2),"irrelevant",
        IF(NOT(CONTAINS(Table1, [ID], [ID])), "not included in Date1",
        IF(NOT(CONTAINS(Table2, [ID], [ID])), "not included in Date2",
        "included in Date1 and Date2")))

 

 

This seems to work well, but I need to get the two timestamps as parameter, selectable by the user. The user should be able to select an existing timestamp, not to enter any date (instead of hard coded variables in line 2 and 3 above). How can this be done? Is there any more elegant way to do the comparison?

Attached (corrected link) you´ll find the pbix file. Any comments are appreciated.

Regards,

Thomas

2 REPLIES 2
stevedep
Memorable Member
Memorable Member

Hi,

 

Perhaps the following is what you are looking for. This will check per code if the number of dates is equal to the number of selected dates, if so they appear in both (or more).

 

 

 

PresentInBoth = 
var NumberOfDates = CALCULATE(DISTINCTCOUNT(Table1[Date]);all(Table1);ALLSELECTED(Table1[Date]))
return 
CALCULATE(DISTINCTCOUNT(Table1[Date])) = NumberOfDates

 

 

 

Kind regards,

 

Steve. 

 

Please accept as solution if this is what you are looking for.

Hi @stevedep,

thank you for this hint, but I could not manage to get a solution. It seems to me, that it is not possible to use this context, because either it filters the target table in a way not intended, or it does not work at all.

Regards,

Thomas.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Users online (548)