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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Twizxup
Frequent Visitor

Measure to Calculate the Difference between two values using different logic

Hi All,

 

I have the below table that tracks joiners & leavers in a given week:

 

Report DateReport Date IndexJoinersLeavers
12/31/2024110
12/31/2024111
12/31/2024100
1/7/2025201
1/7/2025200
1/7/2025210
1/14/2025301
1/14/2025311
1/14/2025310
1/21/2025401
1/21/2025400
1/21/2025400
1/28/2025510
1/28/2025511
1/28/2025501
1/31/2025610
1/31/2025601
1/31/2025601

 

I need to calculate the number of net joiners/leavers for a given month based on the following logic:

 

Joiners = Sum of Joiners in a given month based on the month of the Report Date

Leavers = Sum of Leavers in a given month where the Report Date Index is shifted forward by 1 (i.e. January Leavers = sum of Leavers from 12/31/2024 - 1/28/2025, and February Leavers would start at 1/31/2025)

 

Using this logic, the returned values would be:

 

December Joiners = 2

December Leavers = 0 (nothing in the data would be considered December Leavers)

December Net = 2

 

January Joiners = 6

January Leavers = 7

January Net = -1

 

Any help would be hugely appreciated! Thank you in advance!

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

I've created a date table to grab the month:

vicky__1-1741643510023.png

And then created two measures:

_Joiners = SUM('Table'[Joiners])
_Leavers = 
var indexes = SELECTCOLUMNS(ADDCOLUMNS(VALUES('Table'[Report Date Index]), "index minus 1", 'Table'[Report Date Index] - 1), [index minus 1]) 
RETURN CALCULATE(SUM('Table'[Joiners]), 'Table'[Report Date Index] in indexes, REMOVEFILTERS('Date Table'))

which gives this result:

vicky__2-1741643554443.png

You can then create a third measure to grab the net joiners:

_Net Joiners = [_Joiners] - [_Leavers]

Hope this helps

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

I've created a date table to grab the month:

vicky__1-1741643510023.png

And then created two measures:

_Joiners = SUM('Table'[Joiners])
_Leavers = 
var indexes = SELECTCOLUMNS(ADDCOLUMNS(VALUES('Table'[Report Date Index]), "index minus 1", 'Table'[Report Date Index] - 1), [index minus 1]) 
RETURN CALCULATE(SUM('Table'[Joiners]), 'Table'[Report Date Index] in indexes, REMOVEFILTERS('Date Table'))

which gives this result:

vicky__2-1741643554443.png

You can then create a third measure to grab the net joiners:

_Net Joiners = [_Joiners] - [_Leavers]

Hope this helps

amitchandak
Super User
Super User

@Twizxup ,

Join report date with date of date table and then have measure like

 

calculate(Sum(Table[Leavers]), dateadd(Date[Date], 1, day))

 

Use month year, qtr or any other period from the date table in visual and calculations

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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