Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowHi all,
Due to the proprietory reason I can't disclose the full dataset but I am creating some mock tables with data to let you know my issue. I really need help, I have exhausted all the options that I can think of. Here is a sample data set, it includes the PolicyNumber, Effective Date of the Policy, Transaction Date and the Premium.
PolicyNumber | Effective Date | TransactionDate | Premium |
xyz | 2/7/2024 | 2/29/2024 | 200 |
xyz | 2/7/2024 | 3/2/2024 | 100 |
xyz | 2/7/2024 | 3/5/2024 | 100 |
In the power bi, I have this fact data and a Calendar table. The relationship between Calendar[Date] and TransactionDate is an Active one and Calendar[Date] and Effective Date is an inactive one.
I have following DAX set up to calculate the Premium with respect to Transaction and Effective Date.
EP = SUM(premium_data[Premium])
EP PolicyYear = CALCULATE(EP, USERELATIONSHIP(Calendar[Date], premium_data[EffectiveDate])).
Here is the sample result that this will produce:
Month | EP | EP PolicyYear |
Feb | 200 | 400 |
March | 200 | 0 |
This is all fine but when I add a Date slicer in the mix, and slice the date to show data from 2/1/2024-2/29/2024, the EP PolicyYear still shows 400. I need to show 200.
Please help!
Solved! Go to Solution.
Can you add a 1-2 more instances into your dummy data to show how the measure should behave? Maybe provide a little more context? I wrote a measure that provides the desired output, but I'm not sure this actually is what you want.
EP PolicyYear =
SUMX(
CALCULATETABLE(
VALUES(premium_data[EffectiveDate]),
USERELATIONSHIP(
'calendar'[Date],
premium_data[EffectiveDate]
)
),
CALCULATE(
SUM(premium_data[Premium]),
CALCULATETABLE(
ALLSELECTED('calendar'[Date])
)
)
)
Do I understand correctly that you want: sum of premiums within visual's month per their effective date, but then the outside date slicer should filter policies by their transaction date? Does the date slicer still filter the months in the visual? Example:
PolicyNumber | Effective Date | TransactionDate | Premium |
xyz | 7/1/2024 | 7/1/2024 | 50 |
xyz | 8/1/2024 | 7/1/2024 | 75 |
If the date slicer is set to 7/1/2024..7/31/2024, should the visual show:
Month | EP | EP PolicyYear |
Jul | 125 | 50 |
Aug | 75 |
OR
Month | EP | EP PolicyYear |
Jul | 125 | 50 |
(this is what the measure above is doing - ie the date slicer is still filtering the date month in the visual)
Can you add a 1-2 more instances into your dummy data to show how the measure should behave? Maybe provide a little more context? I wrote a measure that provides the desired output, but I'm not sure this actually is what you want.
EP PolicyYear =
SUMX(
CALCULATETABLE(
VALUES(premium_data[EffectiveDate]),
USERELATIONSHIP(
'calendar'[Date],
premium_data[EffectiveDate]
)
),
CALCULATE(
SUM(premium_data[Premium]),
CALCULATETABLE(
ALLSELECTED('calendar'[Date])
)
)
)
Do I understand correctly that you want: sum of premiums within visual's month per their effective date, but then the outside date slicer should filter policies by their transaction date? Does the date slicer still filter the months in the visual? Example:
PolicyNumber | Effective Date | TransactionDate | Premium |
xyz | 7/1/2024 | 7/1/2024 | 50 |
xyz | 8/1/2024 | 7/1/2024 | 75 |
If the date slicer is set to 7/1/2024..7/31/2024, should the visual show:
Month | EP | EP PolicyYear |
Jul | 125 | 50 |
Aug | 75 |
OR
Month | EP | EP PolicyYear |
Jul | 125 | 50 |
(this is what the measure above is doing - ie the date slicer is still filtering the date month in the visual)
I just tried your code and this is actually working. Thank you
Hi, I added more data to help you visualize the output I am looking for.
PolicyNumber | EffectiveDate | TransactionDate | Premium |
ABC275 | 1/3/2024 | 1/31/2024 | 31.5956 |
ABC275 | 1/3/2024 | 1/31/2024 | 0 |
ABC275 | 1/3/2024 | 1/31/2024 | 5.04918 |
ABC275 | 1/3/2024 | 1/31/2024 | 0 |
ABC275 | 1/3/2024 | 2/29/2024 | 2.06011 |
ABC275 | 1/3/2024 | 2/29/2024 | 13.6284 |
ABC275 | 1/3/2024 | 2/29/2024 | 0 |
ABC275 | 1/3/2024 | 2/29/2024 | 0 |
ABC275 | 1/3/2024 | 2/29/2024 | 0 |
ABC275 | 1/3/2024 | 2/29/2024 | 247.53 |
ABC275 | 1/3/2024 | 2/29/2024 | 0 |
ABC275 | 1/3/2024 | 3/31/2024 | 0 |
ABC275 | 1/3/2024 | 3/31/2024 | 0 |
ABC275 | 1/3/2024 | 3/31/2024 | 264.601 |
ABC275 | 1/3/2024 | 3/31/2024 | 0 |
ABC275 | 1/3/2024 | 3/31/2024 | 28.0355 |
ABC275 | 1/3/2024 | 3/31/2024 | 44.3825 |
ABC275 | 1/3/2024 | 4/30/2024 | 33.8525 |
ABC275 | 1/3/2024 | 4/30/2024 | 0 |
ABC275 | 1/3/2024 | 4/30/2024 | 5.40984 |
ABC275 | 1/3/2024 | 4/30/2024 | 42.9508 |
ABC288 | 2/5/2024 | 2/29/2024 | 6.81421 |
ABC288 | 2/5/2024 | 2/29/2024 | 0 |
ABC288 | 2/5/2024 | 2/29/2024 | 62.6749 |
ABC288 | 2/5/2024 | 3/31/2024 | 15.2459 |
ABC288 | 2/5/2024 | 3/31/2024 | 43.112 |
ABC288 | 2/5/2024 | 3/31/2024 | 6.35246 |
ABC288 | 2/5/2024 | 4/30/2024 | 2.45902 |
ABC288 | 2/5/2024 | 4/30/2024 | 7.04918 |
ABC288 | 2/5/2024 | 4/30/2024 | 0 |
ABC288 | 2/5/2024 | 4/30/2024 | 64.8361 |
Now, based on the measure I have mentioned above. If i create a matrix this is the result I get.
But when I move the slicer, to 1/1/2024 - 2/29/2024, the EP PolicyYear does not filter out. What I need is whenever a slicer is moved, the table should filter the Transaction Date to show data from 1/1/2024-2/29/2024. Once the filter is applied, then I need the EP PolicyYear to calculate.
This is the output I get:
This is the output I need:
Year | EP | EPPolicyYear |
January | 36.64 | 299.86 |
February | 332.71 | 69.49 |
Try wrapping the CALCULATE into another CALCULATE and adding CROSSFILTER:
CALCULATE(
CALCULATE(
EP,
USERELATIONSHIP(
Calendar[Date],
premium_data[EffectiveDate]
)
),
CROSSFILTER(
Calendar[Date],
prem[TransactionDate],
None
)
)
The logic of this is enabling the inactive relationship, then disabling the active relationship with the second calculate.
I tried this, the EP PolicyYear does not update when the slicer is moved. I added some more data in the comment above.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
24 | |
15 | |
13 | |
12 | |
8 |
User | Count |
---|---|
30 | |
22 | |
15 | |
14 | |
14 |