Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have Table A with Date and Session columns. Using Date column i have to create 4 different Date range filters like Start Date, End Date, Compare Start Date, Compare End Date.
Thanks in Advance
Thanks Jing.
One question is that formula is restricted to Channel_grouping only.
But I have additional filters added like Source, medium,campagin.When i select source as filter, session% values are not showing the correct results.(Attached screenshot for reference)
1. When i select StartDate filter range, Sessions calculations is working fine.
2. When i select CompareStartDate filter range, Sessions% calculations is not working as expected.
So, i removed the exception from the below dax which is not correct result.
Dax===
Sessions4num =
CALCULATE(
DISTINCTCOUNT('st_sessions_new'[session_id]),
'st_sessions_new'[date] >= SELECTEDVALUE('DimDate'[StartDate])
)
Sessions4den =
VAR vStartDate = MIN(DimCompareDate[Date])
VAR vEndDate = MAX(DimCompareDate[Date])
RETURN
CALCULATE(DISTINCTCOUNT('st_sessions_new'[session_id]),
ALLEXCEPT('st_sessions_new','st_sessions_new'[channel_grouping]),
'st_sessions_new'[date]>=vStartDate, 'st_sessions_new'[date]<=vEndDate)
Dax used are:
Sessions% = DIVIDE([Sessionsnum],[Sessionsden],0) - 1
Session_numerator=
CALCULATE(
DISTINCTCOUNT('st_sessions_new'[session_id]),
'st_sessions_new'[date] >= SELECTEDVALUE('DimDate'[StartDate])
)
Sessions_Denominator =
VAR vStartDate = MIN(DimCompareDate[Date])
VAR vEndDate = MAX(DimCompareDate[Date])
RETURN
CALCULATE(DISTINCTCOUNT('st_sessions_new'[session_id]),
ALLEXCEPT('st_sessions_new','st_sessions_new'[channel_grouping]),'st_sessions_new'[date]>=vStartDate, 'st_sessions_new'[date]<=vEndDate)
Please try this. I modified it to use REMOVEFILTERS function instead. This function will remove the filter from the DimDate table while respecting all other filters in the current context.
Best Regards,
Jing
Hi Jing,
I tried using the same but i am getting blank records.
I tried using userelationship function, keep fitlers, treatas function, nothing has worked on
Reason: I dont have active relationship with st_sessions_new and Dimcompare Table.
Below are the dax i tried:
Sessions5den =
VAR vStartDate = MIN(DimCompareDate[Date])
VAR vEndDate = MAX(DimCompareDate[Date])
RETURN
CALCULATE(
DISTINCTCOUNT('st_sessions_new'[session_id]),
'st_sessions_new'[date] >= vStartDate,
'st_sessions_new'[date] <= vEndDate,
USERELATIONSHIP('st_sessions_new'[date], 'DimCompareDate'[Date])
=============
Sessions_Denominator =
VAR vStartDate = MIN(DimCompareDate[compareDate])
VAR vEndDate = MAX(DimCompareDate[compareDate])
RETURN
CALCULATE(
DISTINCTCOUNT('st_sessions_new'[session_id]),
FILTER(
ALLSELECTED('st_sessions_new'),
'st_sessions_new'[date] >= vStartDate &&
'st_sessions_new'[date] <= vEndDate
)
)
================
Sessions_Denominator =
VAR vStartDate = MIN(DimCompareDate[compareDate])
VAR vEndDate = MAX(DimCompareDate[compareDate])
RETURN
CALCULATE(
DISTINCTCOUNT('st_sessions_new'[session_id]),
KEEPFILTERS(
'st_sessions_new'[date] >= vStartDate &&
'st_sessions_new'[date] <= vEndDate
)
)
=====
Thanks in advance if you could help me on .
Cheers,
SaiPerumal
Hi Jing,
Here is the DM used.
I tired all feasible ways like userelationship function, keep fitlers, treatas function, nothing has worked on so far.
Example:
cheers,
SaiPerumal.
Thanks Jing.
I have sorted out Range filter now. I have an other query
Need to calculate Revenue based on the dates (Screenshot for example)
Start and End Date range
Compare Start and end date Range
Session % = Dates bw start and end of revenue calculation/ dates bw compare start and end Date Range of revenue calculation
DAx Used :
You need two date tables, one for the first date slicer and the other for the comparison range slicer.
Relationships:
As the relationship exists between DimDate table and the fact table, the revenue measure could be:
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
If you want to filter a date range with only one date column, it's recommended to modify the date slicer to date range mode (Between style). Create a numeric or date range slicer in Power BI - Power BI | Microsoft Learn
Also, there are some custom visuals that could be an alternative.
If I understand it correctly, you want to compare data in two different periods. In this case, you need to have two date tables for two date range slicers. Then use measures to calculate the results for comparing. Here is a similar blog for your reference: How to compare data in different date ranges - Microsoft Fabric Community
If you hope to use four slicers and their picked date should be independent, you need to have four date tables which are disconnected with each other. Once any date table is connected with another one (or two slicers share the same date column), they will be affected by the filtering interaction behavior between the slicers.
Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
78 | |
59 | |
35 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
47 | |
41 |