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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Making relationship between Two Date Series

Hello,

Below are the two visuals, I want to create single visual combining them. There are two tables with dates (multiple values) and losses. How can I create a relationship, so that user can get visual- Chart 3, where he can drill down from Year- Quarter- Month- Day- Day of the hour. Or if Date-Hierarchy is not possible, how to can I create Chart3 without drill downs.

prafull2013_1-1639983027954.pngColumns: ID (unique), Date, hour of Day, loss in Min (all columns have duplicates)

prafull2013_3-1639983114570.pngColumns: ID (unique)Date2, hour of Day, loss in Min (all columns have duplicates)

Chart 3

prafull2013_4-1639983204352.png

 

What I need is a way to aggreagate "Loss in Min" by Date fields in both tables and create a single visual. If I put relation on ID columns, I get wrong values. and if I try putting many-many relation on "Date" column nothing is shown.

 

 

 

 

 

1 ACCEPTED SOLUTION

Have a look at:
Demo File 


I changed the shift date columns to Date type (not date time).

 

I created a date table with:

Date = 
VAR MinYear = 2021
VAR MaxYear = 2021
RETURN
ADDCOLUMNS (
    CALENDAR( DATE ( MinYear, 1, 1 ), DATE ( MaxYear, 12, 31 ) ),
    "Calendar Year", "CY " & YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Month Year", DATE ( YEAR( [Date] ), MONTH ( [Date] ), 1 ), //Format as mmm YYYY
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)

and an Hour table with:

Hour = 
GENERATESERIES( 1, 24, 1 )

(and renamed the single column it creates to Hour of Day)

Linking it all up in data model:

bcdobbs_0-1639996089523.png


I did have to delete your existing visuals because it wouldn't let me clear existing filters.
However you can put the following on shared axis:

bcdobbs_1-1639996172466.png

A pre built hierachy can't span two tables which is why I've done it this way.


Also best practice would be once you calculate the hour flag in power query throw away the t_stamp column if you no longer use it as it will cause your model to be much bigger.





Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

7 REPLIES 7
C2
Frequent Visitor

C2_0-1692971131307.png similar issue here, I have 2 tables 1 is manually created & the other is a direct query table, Im trying to create a relation between Shipped Date from direct query table & Date from the manual forecast table, im able to make the relationship, however when I create a "slicer" with either Shipped Date , or Date it only updates the visuals with date from their tables, please help  

 

bcdobbs
Community Champion
Community Champion

Hi,

You need a date table that has a single row for each date and columns for all the different descriptions like quarters. You then relate that to your two tables through 1 to many relationships. If you then use fields from that date table in visuals they all update together.

 

You can create date tables in lots of ways but one way is straight in DAX:

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Thanks for the reply. I was thinking of using date-hierarchy to navigate from Year to Day. And there is additional column named "Date of the hour"- it has values from 1-24, it will last level. Will this be possible.

and I didn't get this part of your solutions-


@bcdobbs wrote:

Hi,

You need a date table that has a single row for each date and columns for all the different descriptions like quarters. You then relate that to your two tables through 1 to many relationships. If you then use fields from that date table in visuals they all update together.

 

You can create date tables in lots of ways but one way is straight in DAX:

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/


 

All possible. Hours of the day changes slightly as wouldn't normally split time and date apart.


In reference to the bit of my explanation a date table just has columns for any date related attribute you want to slice by so for example would have columns:

Date, Start of Month, Quarter, Week Number etc

 

If you mock up some demo data that matches your existing structure and send a pbix file I'll have a go at implementing so you can see what I mean.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Hi,

Below link has PBIx file and two csv files with dummy data with exact structure. It would be awesome check it out.

Demo Links

 


@bcdobbs wrote:

All possible. Hours of the day changes slightly as wouldn't normally split time and date apart.


In reference to the bit of my explanation a date table just has columns for any date related attribute you want to slice by so for example would have columns:

Date, Start of Month, Quarter, Week Number etc

 

If you mock up some demo data that matches your existing structure and send a pbix file I'll have a go at implementing so you can see what I mean.


 

Have a look at:
Demo File 


I changed the shift date columns to Date type (not date time).

 

I created a date table with:

Date = 
VAR MinYear = 2021
VAR MaxYear = 2021
RETURN
ADDCOLUMNS (
    CALENDAR( DATE ( MinYear, 1, 1 ), DATE ( MaxYear, 12, 31 ) ),
    "Calendar Year", "CY " & YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Month Year", DATE ( YEAR( [Date] ), MONTH ( [Date] ), 1 ), //Format as mmm YYYY
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1
)

and an Hour table with:

Hour = 
GENERATESERIES( 1, 24, 1 )

(and renamed the single column it creates to Hour of Day)

Linking it all up in data model:

bcdobbs_0-1639996089523.png


I did have to delete your existing visuals because it wouldn't let me clear existing filters.
However you can put the following on shared axis:

bcdobbs_1-1639996172466.png

A pre built hierachy can't span two tables which is why I've done it this way.


Also best practice would be once you calculate the hour flag in power query throw away the t_stamp column if you no longer use it as it will cause your model to be much bigger.





Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Anonymous
Not applicable

Thanks !! This is what I was looking for.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors