Forum Discussion

José2410's avatar
José2410
Regular Visitor
2 years ago
Solved

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.

 

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]))
  • Anonymous's avatar
    Anonymous
    2 years ago

    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

2 Replies