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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
PBIDEV_10
Helper II
Helper II

Total sum calculations based on year

Hi

I am working on a member dataset. Where the data is at date level. Data looks like:

MemberNo.Active flagDateFeePaidDateDifference in yearsPrice per year
111/1/202312/31/2022-1300
111/2/202312/31/2022-1300
111/3/202312/31/2022-1300
111/4/202312/31/2022-1300
111/5/202312/31/2022-1300
111/6/202312/31/2022-1300
111/7/202312/31/2022-1300
111/8/202312/31/2022-1300
211/1/202312/31/2022-1300
211/2/202312/31/2022-1300
211/3/202312/31/2022-1300
211/4/202312/31/2022-1300
211/5/202312/31/2022-1300
211/6/202312/31/2022-1300
211/7/202312/31/2022-1300
211/8/202312/31/2022-1300
1011/1/202312/31/2021-2300
1011/2/202312/31/2021-2300
1011/3/202312/31/2021-2300
1011/4/202312/31/2021-2300
1011/5/202312/31/2021-2300
1011/6/202312/31/2021-2300
1011/7/202312/31/2021-2300
1011/8/202312/31/2021-2300
1101/1/202312/31/2020-3300
1101/2/202312/31/2020-3300
1101/3/202312/31/2020-3300
1101/4/202312/31/2020-3300
1101/5/202312/31/2020-3300
1101/6/202312/31/2020-3300
1101/7/202312/31/2020-3300
1101/8/202312/31/2020-3300

Now I want to generate following matrices: 

 

Difference YearNo. of Inactive membersTotal sum to be paid
This year (0)  
Last year (-1)  
Last to last year (-2)  
More than 2 years (-3)1900

 

Difference YearNo. of Active membersTotal sum to be paid
This year (0)  
Last year (-1)2600
Last to last year (-2)1300
More than 2 years (-3)  

 

How can I achieve that with DAX? I tried to implement like this but gives wrong result:

 

Total sum to be paid = 
VAR DifferenceYear = CALCULATE(SUM(Fact_table[DifferenceYear]), LASTDATE(Date[Date]))
VAR PricePerYear = CALCULATE(SUM(Fact_table[PricePerYear]), LASTDATE(Date[Date]))
RETURN DifferenceYear * PricePerYear 

 

Regards

PGP

2 REPLIES 2
amitchandak
Super User
Super User

@PBIDEV_10 ,

 

Based on what I got , a new measure 

 

sumx(Values(Fact_table[MemberNo]), [Total sum to be paid])

 

Or a combination these two

 

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/b...
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retenti...

 

 

and

 

https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak . Thank you for your reply. But I didnot understand the solution you gave. I need to pick up the last row for each member from the fact table and use price per year and difference in year. But when I use SUM in the variable, it gives me vague results.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors