The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Good moring, everyone,
I have a measure [Premium] works under different contexts, except for date.
For example, if I want to group by Month, it always returns the a constant Total amount for each month, without any filtering.
Appreciate your help.
Dennis
Premium =
VAR CurrentYear = YEAR(MAX(DateIndex[AS_OF_DATE]))
VAR LatestDate = MAX(DateIndex[AS_OF_DATE])
RETURN
CALCULATE (
SUM(PolicyData[NET_PREMIUM]),
DateDim[Year] = CurrentYear,
DateDim[Date] <= LatestDate,
PolicyData[NET_PREMIUM] <> 0 )
@12Bowers12 what is dateindex table? Why are you doing filter on year and latest date? If you have a direct relationship with your date table and transaction table, you can simply show sum using month from date dimension. Seems like I'm missing something here.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you, Mr. Prray, I think your point is right.
What I really needs is to aggregate the premium on monthly basis for the current calendar year 2020 as of the evaluation date such as 06/30/2020.
DateDim table covers many years including such as future calendar year such as 2021, 2022, etc.
To deal this issue, I created a table with one row and one column only showing the [As_Of_Date] 06/30/2020.
I tested if use the filter argument as below, it works but very slow.
Any improvements or solutions?
Dennis
Premium_Filter =
VAR CurrentYear = YEAR(MAX(DateIndex[AS_OF_DATE]))
VAR LatestDate = MAX(DateIndex[AS_OF_DATE])
RETURN
CALCULATE (
SUM(PolicyData[NET_PREMIUM]),
DateDim[Year] = CurrentYear,
DateDim[Date] <= LatestDate,
FILTER( PolicyData, CALCULATE(SUM(PolicyData[NET_PREMIUM])) <> 0 ))
Hi @12Bowers12 ,
Why you need FILTER( PolicyData, CALCULATE(SUM(PolicyData[NET_PREMIUM])) <> 0 ) in your formula?
Best Regards,
Dedmon Dai
Thank you, Dedmon,
Without this filtering argument, the measure could not group the premium on monthly basis. But I don't know why.
Regards,
Dennis
Hi @12Bowers12 ,
I suggest you create the following measure without creating new table for one cell:
Premium_Filter =
VAR _parameter = ...
VAR CurrentYear = YEAR(_parameter)
VAR LatestDate = _parameter
RETURN
CALCULATE (
SUM(PolicyData[NET_PREMIUM]),
DateDim[Year] = CurrentYear,
DateDim[Date] <= LatestDate,
SUM(PolicyData[NET_PREMIUM])) <> 0 )
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Thank you, Dedmon,
I tried but it didn't return any value. I will test it again later.
Dennis
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
182 | |
81 | |
64 | |
46 | |
41 |