
How to Compare Date Ranges in Flexa Tables for Power BI
Do you want to compare data across specific date ranges in your Power BI reports — such as January 3–15, 2021 vs January 3–15, 2022? With Flexa Tables, you can achieve this with a simple workaround. While Flexa Tables handles standard MoM, YoY, and YTD comparisons natively through the Analytics panel, custom date range comparisons use a calculated column to define the periods you want, then let Flexa Tables do the rest.
Why Compare Date Ranges?
Comparing data across specific periods — sales performance, inventory levels, financial metrics — helps uncover trends and drive better decisions. Standard time intelligence functions handle calendar periods (same month last year, YTD), but they can't compare custom windows like a 13-day promotional period, a fiscal quarter with non-standard dates, or a specific operational event window.
The DateRangeBucket approach gives you full control: define any periods you want, give them meaningful labels, and Flexa Tables handles the side-by-side comparison and variance calculation automatically.
Sample data PBIX: download here
Step 1 — Create a Calculated Column for Date Ranges
First, create a calculated column that categorizes your dates into named buckets. Each bucket represents one date range you want to compare.
- Open Power BI Desktop and navigate to the Modeling tab.
- Select your data table (e.g. SalesData) and click New Column.
- Name the column
DateRangeBucketand paste the DAX below, replacingEnergywith your actual table name:
DateRangeBucket =
VAR SelectedDate = MAX('Energy'[Delivery Date])
-- Replace 'Energy' with your actual table name
RETURN
SWITCH(
TRUE(),
SelectedDate >= DATE(2021,1,3) && SelectedDate <= DATE(2021,1,15), "Jan3-15-2021",
SelectedDate >= DATE(2022,1,3) && SelectedDate <= DATE(2022,1,15), "Jan3-15-2022",
"Other"
)Jan3-15-2021Jan3-15-2022OtherStep 2 — Add DateRangeBucket to Flexa Tables
Now that your dates are categorized, use Flexa Tables to compare data across the buckets.
- Add a Flexa Tables visual to your Power BI report canvas.
- Drag the
DateRangeBucketcolumn to the Columns field in the Flexa Tables visual.
- Add the metrics you want to compare (Sales, Revenue, Units Sold, etc.) to the Values field.
Step 3 — Enable Comparison in the Analytics Panel
The Analytics panel is where Flexa Tables calculates variance across your defined buckets.
- Select the Flexa Tables visual in your report.
- Click the Analytics tab in the Flexa Tables toolbar.
- In the Compared By section, select the
DateRangeBucketcolumn. This tells Flexa Tables to compare data across the two buckets (Jan3-15_2021 and Jan3-15_2022).
Step 4 — Visualize and Analyze
Once configured, Flexa Tables displays your data side by side for the two date ranges. For example:
You can further enhance your analysis by:
- Conditional Formatting — highlight differences automatically (green for improvement, red for decline)
- Charts in Tables — add inline sparklines to visualize trends within the Flexa Tables visual
- Interactive Formulas — calculate percentage growth or absolute variance using the Analytics panel's built-in ΔVar and ΔVar% options
Tips for Success
Ensure your Date column is in the correct date format in Power BI — not text or mixed types. If the column isn't recognized as a date, the DAX
DATE() comparisons will silently return incorrect results.
Adjust the DAX code to include additional date ranges or change the labels to match your business terminology —
Q1_2021 instead of Jan3-15-2021, for example. You can add as many SWITCH conditions as needed.
For a polished look, apply the custom theme from flexaintel.com/theme. Download the JSON file, go to Power BI's View → Themes → Browse for themes, and import it to unify your report's visuals.
Have questions or need help setting up your date range comparison? Contact us at support@flexaintel.com.
