Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
amit_darak
Frequent Visitor

Existing data vs corresponding previous data comparison

Hi,

 

I am currently working with insurance data where policy gets renewed or new policy is placed. I want to achieve something like this:-

There is a policy ABC-2021 which gets renewed and policy no changes to ABC-2022. This policy again gets renewed next year and becomes policy ABC-2023 and so on. I have data in below format.

 

amit_darak_0-1686750304194.png

 

My objective is whenever I select any policy no, I should see its previous policy performance. For eg if I select ABC-2023, I should see data for ABC-2022 as well like in the below chart.

amit_darak_2-1686750955635.png

I have written below DAX
last_year_value =

var prev_policy = MAX(Sheet1[Previous policy no])
var prev_sum =
SUMMARIZE(
FILTER(
SUMMARIZE(ALL(Sheet1), Sheet1[Policy no], Sheet1[Amount]),
Sheet1[Policy no] = prev_policy),
Sheet1[Amount]
)
 
return
SUMX(prev_sum,Sheet1[Amount])
 
But I get aggregated value on month column ie 204 which is sum of all 4 months whereas it should be - Apr-35, Feb-65, Jan-12, Mar-91
 
amit_darak_0-1686824322814.png

 


 

What am I missing?

 

 

Regards,

Amit Darak

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

It's much simpler.

 

lbendlin_0-1686884473445.png

 

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

It's much simpler.

 

lbendlin_0-1686884473445.png

 

Hi,

 

It worked well when I didn't use the filter function.

I tried using this dax with filter function, it gave me blank values.

last_year_value =
var prev_policy = MAX(Sheet1[Previous policy no])
var ly_value = CALCULATE(SUM(Sheet1[Amount]),FILTER(Sheet1, Sheet1[Policy no] = prev_policy))      
return
ly_value
 
Any idea why it gives blank values. As I have to apply multiple filters in my formula, this isn't working in my original work.
 
Regards,
Amit 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi,

 

I think I complicated it unnecessarily. It was pretty simple.

 

Thanks.

 

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.