Forum Discussion

aitorcalero's avatar
aitorcalero
New Member
9 years ago

Create relationships using dates

Hello, I have two tables that I want to relate. The two tables have the same fields but one is for incomes and the other is for expenses correponding to the same year. I would like to relate the two tables so that when I hit quarter in the income table, for instance, I automatically see the correponding Q filtered in the expenses table.

 

How can I do that? If I want to create the relationship using the date field, PBI says that I need a unique field. Should I have to build an intermediate table to link them?

 

Thanks in advance.

4 Replies

  • ImkeF's avatar
    ImkeF
    Community Champion

    I would recommend to append both tables instead. But before you do that, add a column called "Source" to your income table with "income" and the same with "expense" for your expenses table.

     

    That way you just have one date-column and both values will be filters simultaneously.

    Drag the field "Source" into your report in order to distinguish between both values.

    • ImkeF's avatar
      ImkeF
      Community Champion

      Otherwise you would have to create a calendar/date-table to combine both tables on its date-field.

  • Hello, I have two tables that I want to relate. The two tables have the same fields but one is for incomes and the other is for expenses correponding to the same year. I would like to relate the two tables so that when I hit quarter in the income table, for instance, I automatically see the correponding Q filtered in the expenses table.

     

    How can I do that? If I want to create the relationship using the date field, PBI says that I need a unique field. Should I have to build an intermediate table to link them?

     

    Thanks in advance.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi aitorcalero,

      You can create a calendar table following the instructions in this blog, then create relationships between tables as ImkeF's post, you can check the example as follows.


      After that, you can create visuals using date field from calendar table and related fields from income and expenses table, then filter the visual from quarter slicer.



      For more deatils, you can review the example in the attached PBIX file.


      Thanks,
      Lydia Zhang