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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Loubot3000
Resolver II
Resolver II

Compare date table with another unrelated date table

I'm using a slicer that uses an unrelated date table to set the maximum date of the main date table, without filtering that main table to a single month (like what would happen if the slicer were using the main date table instead).

 

However, since they're unrelated, the date comparison ( Datetable1 <=  Selected(DateTable2) ) won't work.

 

This is my code for a calculated column, which will be put into a table:

 

------------------------------------------------------------------------------

 

Test 2 (filtered date column) =

VAR currMonth =
    SELECTEDVALUE('Independent Date Table'[Date])
// Recalculated for every date selection.

VAR currPeriod =
    FILTER(
        ALLSELECTED(Sheet1[Period - month]),
        Sheet1[Period - month] <= currMonth
    )
// ALLSELECTED() Excludes months that are missing within the context (e.g. months measured quarterly) - causing it to be non-consecutive.

RETURN currPeriod
 
---------------------------------------------------------------------
 
The bit in red seems to not be evaluating correctly, it seems to just be returning false for everything, and therefore returning a blank table.
 
I have tried adding an inactive relationship between the two date columns, and then using USERELATIONSHIP() to activate it just during the calculation, like so:

--------------------------------------------------------------------
Test 2 (filtered date column) =

VAR currMonth =
    SELECTEDVALUE('Independent Date Table'[Date])
// Recalculated for every date selection.

VAR currPeriod =
    FILTER(
        ALLSELECTED(Sheet1[Period - month]),
        CALCULATE(SELECTEDVALUE(Sheet1[Period - month]) <= currMonth,
        USERELATIONSHIP(Sheet1[Period - month], 'Independent Date Table'[Date]))
    )
/*ALLSELECTED() Excludes months that are missing within the context (e.g. months measured quarterly) - causing it to be non-consecutive.
USERELATIONSHIP() activates the relationship with the independent date table just for this calculation, so that the date comparison can work. */

RETURN currPeriod

-------------------------------------------------------------------

However this still returns a blank column.

What am I doing wrong? Is there a better way to do this?
2 REPLIES 2
BITomS
Resolver III
Resolver III

Hi @Loubot3000 ,

 

Have you tried the LOOKUPVALUE expression? : https://learn.microsoft.com/en-us/dax/lookupvalue-function-dax

How would you suggest using it in this context?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.