Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!View all the Fabric Data Days sessions on demand. View schedule
Hello,
I've read many posts in this forum but did not find one answering my question.
I have a data model with a DimDate table (days from 01.2018 to today) and another table with Traffic (Google Analytics users) data, on a day basis. Both tables are connected in the data model (via the date dimension).
I have a slicer to allow report users to filter on dates.
I created a measure to calculate the traffic of the previous period. I don't use timeintelligence functions because I want the users to be able to select a custom date range (e.g 04/30 to 06/08 as shown above).
Var_Users =
VAR date_range = COUNTA(DimDate[Date])
VAR sum_prevperiod = IF(
date_range=0,0,
CALCULATE(SUM('Raw_Data'[Users]),dateadd(DimDate[Date],-date_range+1,DAY))
)
return sum_prevperiod
This works perfectly fine for "card" or "KPI" visuals for instance: the data displayed is the one from the previous period.
But I'd like to have a line chart comparing the data between the selected period and the previous period.
The issue is: The visual merges both lines into one, showing the same data.
Do you guys have any idea on how I can overcome this?
Thanks!
@mpcbto1 , The information you have provided is not making the problem clear to me. Can you please explain with an example.
Check if this blog can help
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Appreciate your Kudos.
Hello @amitchandak
Thanks for the reply.
I would like to be able to compare the Traffic data between two time periods: the current time period (selected in the slicer shown in my initial post) and the previous time period.
For instance : comparing Traffic data of 04/30/2020-06/08/2020 to 04/29/2020-03/21/2020.
To do this, I have created the measure shown in the initial posts, using DATEADD. This measure works very well when I use "KPI" or "cards" visuals, to show total data (Current period total traffic and Previous period total traffic).
However, I would like to show the variation of Traffic day over day in a Line Chart, and compare it to the previous period.
I would then get a line chart with:
- X axis: days (04/30/2020-06/08/2020 in my example)
- Y axis: Traffic
- 2 lines: traffic of current period (red value in the screenshot) and traffic of previous period (light red value in the screenshot).
- 2 doted trendlines for the current period and previous period
But that does not work, as shown in the screenshot, PowerBi merges both lines into one: apparently the measure I've created does not work for this kind of visualization.
I hope this makes more sense to you!
Thanks again
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!