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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mpmsltd
Helper I
Helper I

Group user transactions per period of time according to hire date (0-3 months), (3-6 months)

Hi All,

 

I have a table the shows user transactions and another table that shows the user id and hire date.

 

I need to count the transactions by groups that correspond to days after hired (0-90 days, 90-180 days and + 180 days). Can someone please help me to get to the expected result below? Thanks!

 

Example

user id 
abc1/1/2019
def3/1/2019
ghi4/1/2019
  
  
Transactions 
abc1/2/2019
abc1/2/2019
abc5/5/2019
def3/1/2019
def4/1/2019
def10/1/2019
def10/2/2019
ghi4/1/2019

 

Expected Result

user id0-9090-180180
abc21 
def2 2
ghi1  

 

1 ACCEPTED SOLUTION
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @mpmsltd ,

I think the easiest way is to add the three columns to your first table with the following calculated columns:

0-90 = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate]
VAR upperDate = HireTable[HireDate]+90 
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate && Transactions[TransactionDate] <= upperDate))
91-180 = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate] + 91
VAR upperDate = HireTable[HireDate] + 180 
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate && Transactions[TransactionDate] <= upperDate))
180 + = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate] + 181
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate))

This results in this:

image.png

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
JarroVGIT
Resident Rockstar
Resident Rockstar

Hi @mpmsltd ,

I think the easiest way is to add the three columns to your first table with the following calculated columns:

0-90 = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate]
VAR upperDate = HireTable[HireDate]+90 
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate && Transactions[TransactionDate] <= upperDate))
91-180 = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate] + 91
VAR upperDate = HireTable[HireDate] + 180 
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate && Transactions[TransactionDate] <= upperDate))
180 + = 
VAR _curUserID = HireTable[user id]
VAR lowerDate = HireTable[HireDate] + 181
RETURN
COUNTROWS(FILTER(Transactions, Transactions[user id] = _curUserID && Transactions[TransactionDate] >= lowerDate))

This results in this:

image.png

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




That's a great solution! Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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