The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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!
User | Count |
---|---|
86 | |
84 | |
36 | |
34 | |
34 |
User | Count |
---|---|
94 | |
79 | |
65 | |
55 | |
52 |