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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OuluChris
Helper I
Helper I

Linking a date table to a list of months

Hi,

 

I have a "standard" date table that looks like this (it's formatted as a date table):

 

DateYearMonth NumberMonthMMM-YY
01/01/202120211JanuaryJan-21
02/01/202120211JanuaryJan-21

 

And a separate table that looks like this (pilled in through a connection and not formatted as a date table):

 

MonthBudget Leave
January0.8
February0.9
March1.1
April1.5
May1.3
June1.7
July2.4
August3.6
September2.3
October1.9
November1.5
December6

 

The values in the second table will be the same every year so they don't need a year adding.

 

What I want to do is link these two together so if I filter for (say) Jan-21 I will get the result of 0.8. Unfortunately, I can't link them together because the second table 'month' column is formatted as text and it won't seem to accept a date format without adding a year. That is precisely what I'm trying to avoid!

 

Thanks,

 

 

Chris

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@OuluChris  Does this help?

_TREATAS = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    TREATAS ( VALUES ( 'Date'[Month] ), tbl2[Month] )
)
_CONTAINSROW = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date',CONTAINSROW(SUMMARIZE(tbl2,tbl2[Month]),'Date'[Month]))
)
_IN = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date','Date'[Month] IN SUMMARIZE(tbl2,tbl2[Month]))
)
_CONTAINS = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date',CONTAINS(SUMMARIZE(tbl2,tbl2[Month]),tbl2[Month],'Date'[Month]))
)
_INTERSECT = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    INTERSECT(VALUES(tbl2[Month]),VALUES('Date'[Month])
))

 

smpa01_1-1638152472307.png

 

 

pbix is attached

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

6 REPLIES 6
v-yingjl
Community Support
Community Support

Hi @OuluChris ,

You can create a one-to-many relationship between two tables based on Month columns and set the cross filter direction to both to get your expected result.

vyingjl_0-1638346506588.png

vyingjl_1-1638346523907.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

smpa01
Super User
Super User

@OuluChris  Does this help?

_TREATAS = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    TREATAS ( VALUES ( 'Date'[Month] ), tbl2[Month] )
)
_CONTAINSROW = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date',CONTAINSROW(SUMMARIZE(tbl2,tbl2[Month]),'Date'[Month]))
)
_IN = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date','Date'[Month] IN SUMMARIZE(tbl2,tbl2[Month]))
)
_CONTAINS = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    FILTER('Date',CONTAINS(SUMMARIZE(tbl2,tbl2[Month]),tbl2[Month],'Date'[Month]))
)
_INTERSECT = 
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    INTERSECT(VALUES(tbl2[Month]),VALUES('Date'[Month])
))

 

smpa01_1-1638152472307.png

 

 

pbix is attached

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@OuluChris  did you have a chance to look into this?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

You may want to clarify that these are several separate solutions. I was a bit confused when I first saw it.

 

Assuming you have the relationship set up as in your .pbix. Here are a couple more options:

_CROSSFILTER =
CALCULATE (
    MAX ( tbl2[Budget Leave] ),
    CROSSFILTER ( 'Date'[Month], tbl2[Month], BOTH )
)
_TABLEFILTER = 
CALCULATE ( MAX ( tbl2[Budget Leave] ), 'Date' )

 

You could also set up the relationship as many-to-many with the date table filtering the budget table but that's not best practice.

@AlexisOlson  Thanks for explaining out that !!!

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
wdx223_Daniel
Super User
Super User

Try link the month column of table2 to the month column of date table. this will not let you benefit the intellegent of time functions. but you can use RELATED function to get the value of table2, assuming the value of table2 is distinct.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors