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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Historic Data by Week Number, Creating a Current Week X-Axis

I'm struggling to get data to show correctly in any chart visual yet the data shows fine in a table format. Most likely because they are 2 seperate tables. Below is the chart as it previously existed in Excel (This was done using static calculations in another Excel sheet and take time every week) Hence moving over to Power BI which would do it automatically. 

 

Incident Chart in ExcelIncident Chart in Excel

Note the black circled x-axis is the week number of the year (of 2018). Now below is the data now in Power BI into a Table Visual. See that the Count figures (taking Week 24 as a example) is the same as the Excel chart, showing to me at least that the data can be matched and verified between Power BI and the Excel Chart (Week 24 for Example show 662 Resolved and 684 Arrived).

 

Incident data in Table VisualIncident data in Table Visual

Brilliant, but unfortunately when trying to stick this into a Chart Visual, the numbers dont match all because i can only use the Arrival Week Number OR Closed Week Number in the X-Axis thus only one set of values is correct. In the below case it will be the bar in Red (Arrivals) because the X-Axis is Arrival Week Number. 

 

Incident Chart in Power BIIncident Chart in Power BI 

So how do i get Current Week into the X-Axis ???

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Yes, I can.

Usually, only one date table is needed. Please refer to the snapshot below. There are two relationships while one is inactive.

// We don't need to use userealtionship() for the active relationship.

_Incidents_Resolved = COUNTROWS(Incidents)
_Incident_Arrivals =
CALCULATE (
    COUNTROWS ( Incidents ),
    USERELATIONSHIP ( Added_Date[DATEKEY], Incidents[Added_Date_Key] )
)

Historic-Data-by-Week-Number-Creating-a-Current-Week-X-Axis

 

 

Best Regards,

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

View solution in original post

8 REPLIES 8
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

You need a date table in your scenario. And then create two relationships but only one is active. Finally you can calculate one value using a measure with userelationship-function-dax. It could be like below.

 

Measure =
CALCULATE (
    COUNTROWS ( 'table' ),
    USERELATIONSHIP ( 'calendar'[date], 'table'[Closed Week Number] )
)

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Many Thanks for this. So here is my DAX

 

_Incident_Arrivals = CALCULATE(COUNTROWS(Incidents),USERELATIONSHIP(Added_Date[DATEKEY],Incidents[Added_Date_Key]))
 
and the same again for Incidents Resolved
 
_Incident_Resolved = CALCULATE(COUNTROWS(Incidents),USERELATIONSHIP(Closed_DateDATEKEY],Incidents[Closed_Date_Key]))
 
Sticking that in the Values and the WeekNum from my Calendar into the Axis gets me the chart below. Somthings not right as you can tell. Both Values are the same
 
Chart after UseRelationship DAXChart after UseRelationship DAX

Hi @Anonymous,

 

Can you share your file? Please mask the sensitive parts first.

Why are there so many date tables like Added_Date, Colsed_Date? Only one date table is needed.

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Can you access the file via this link 

 

Power BI File

Hi @Anonymous ,

 

Could you please mark the proper answers as solutions?

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Hello, I have just got around to testing this out. I will now mark the accepted solution 

 

 

Thanks Again 

Hi @Anonymous,

 

Yes, I can.

Usually, only one date table is needed. Please refer to the snapshot below. There are two relationships while one is inactive.

// We don't need to use userealtionship() for the active relationship.

_Incidents_Resolved = COUNTROWS(Incidents)
_Incident_Arrivals =
CALCULATE (
    COUNTROWS ( Incidents ),
    USERELATIONSHIP ( Added_Date[DATEKEY], Incidents[Added_Date_Key] )
)

Historic-Data-by-Week-Number-Creating-a-Current-Week-X-Axis

 

 

Best Regards,

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-jiascu-msft Again Thanks.  The 2 date tables are there as a colleague suggested as we can't use the one date table to relationshiop between both dates hence 2 tables. 

 

I will now go away and prep a file i can share 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors