The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
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.
Forgive my English, I'm using a translator (in Brazil there are few answers...).
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
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.
User | Count |
---|---|
15 | |
13 | |
8 | |
6 | |
5 |
User | Count |
---|---|
24 | |
20 | |
12 | |
9 | |
7 |