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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Renenzn
Frequent Visitor

Comparison of two different periods in the same table/graph

Hi!

Kindly help,

I have two calendar tables that I use to make comparisons between different periods, but I would like the two measures to be superimposed on the graph, sharing the same axis.

Currently it is like this

Renenzn_0-1695067749121.png

 

Each measure I use a different calendar table with USERELATIONSHIP:
Venda Total A = CALCULATE(SUM(SALES[TOTAL]), USERELATIONSHIP(Calendar1[Date],Sales[Date]))
Venda Total B = CALCULATE(SUM(SALES[TOTAL]), USERELATIONSHIP(Calendar2[Date],Sales[Date]))

The idea is that Period A is the Axis of the graph and Period B follows, starting in the same place as Period A, regardless of the dates. Similar to the Google Analytics system.

Renenzn_1-1695067793779.png


Forgive my English, I'm using a translator (in Brazil there are few answers...).

3 REPLIES 3
johnt75
Super User
Super User

I still think that DATEADD is the way to go, but you could work out the difference between the 2 chosen start dates, e.g.

Venda Total B =
VAR Date1 =
    MIN ( 'Calendar1'[Date] )
VAR Date2 =
    MIN ( 'Calendar2'[Date] )
VAR DaysDiff =
    INT ( Date2 - Date1 )
VAR Result =
    CALCULATE ( SUM ( Sales[Total] ), DATEADD ( 'Calendar1', DaysDiff, DAY ) )
RETURN
    Result
johnt75
Super User
Super User

I don't think you need 2 calendar tables for this. You can just use 1, and use the DATEADD function to shift the dates back by the selected number of days, e.g.

Venda Total B =
VAR VisibleDates =
    COUNTROWS ( 'Calendar1' )
VAR Result =
    CALCULATE ( SUM ( Sales[Total] ), DATEADD ( 'Calendar1', - VisibleDates, DAY ) )
RETURN
    Result

The problem is that it is a comparison of different dates. For example in the image I want to compare the period of
01/01/2023 to 01/15/2023
vs
02/20/2023 to 03/11/2023

They are not equal or equivalent periods, hence two distinct calendar tables. The biggest problem is that I need the lines to overlap on the same graph axis.

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.