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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
José2410
Regular Visitor

relationship between table and visual with 2 different dates

Hello,

I am facing a problem. I am working on a contracts dashboard. For this I am using 2 dates. One date is the end date of the contract, the other date is when a contract should be renewed. Now I managed to get both dates in a bar chart with the userelationship formula in dax.

Jos2410_0-1717398617140.png

 

The only problem is that the table that comes with it does not filter with it, when I select the renewal date. It uses the active relation between date and Enddate.
In my bar chart I want to be able to click on both dates and the table will change with the clicked date. One time the end date, the other time the renewal date.

 

Hopefully you can help me!

 

This is the data I used:

 

I used this table:

end daterenewal datecontract number
6/30/20246/1/2024A1
7/14/20246/14/2024A2
6/20/20246/1/2024A3
7/30/20247/3/2024A4
7/4/20247/3/2024A5
7/30/20246/30/2024A6

 

And this query for a date table (you can paste this in Advanced editor):

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dY5LCsAwCAXv4jqQ56fp2nOI979GidA2pWQ5MswzghQdowvEqBF4AWfKFsTWcd63Ca8gJci+oCXMiacAXcCtBNhWOP6Fz8c+KPMC", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"End date" = _t, #"Renewal date" = _t, #"Contract number" = _t]),
#"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"End date", type date}}, "en-GB"),
#"Changed Type with Locale1" = Table.TransformColumnTypes(#"Changed Type with Locale", {{"Renewal date", type date}}, "en-GB")
in
#"Changed Type with Locale1"

 

After that I made a relation between 'date' and 'end date'. 

After that I made a measure like this: 

Count Renewal Date =
CALCULATE (
    COUNTROWS ( Dates ),
    USERELATIONSHIP ( Dates[Renewal date], 'Calendar'[Date]))
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @José2410,

According to your description and sample data, it seems like a common multiple date fields analysis requirement.
For this scenario, I'd like to suggest you take a look at Greg’s blog to know how to handle with date range analysis requirement.

Before You Post, Read This: start, end date 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @José2410,

According to your description and sample data, it seems like a common multiple date fields analysis requirement.
For this scenario, I'd like to suggest you take a look at Greg’s blog to know how to handle with date range analysis requirement.

Before You Post, Read This: start, end date 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.