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
patricia_csf
Regular Visitor

Datediff multiple rows / group of date periods / distinctcount of users

Hi,

I have two tables (with proper relationship):

1) User ID + registration date

2) User ID + profit per day (several rows)

I would like to have measures to:

- See the difference between registration date and day of profit (problem I have is that I have multiple profit inputs per user ID)

- To be able to split the data as: 

Between 0 and 6 months after registration, "1.000" users (userID) generated a sum of "$10.000" profit

Between 6 and 12 months after registration, "800" users (userID) generated a sum of "$6.000" profit

Between 12 and 18 months after registration, "500" users (userID) generated a sum of "$8.000" profit

Can you help me on the measures?

 

Thx in advance. 🙂

1 ACCEPTED SOLUTION
rcharara
Regular Visitor

Add a new column to your profit table

Delta Profit Months - DATEDIFF(RELATED(CustMaster[Registration Date]),Benefits[Benefit Day],MES)
ProfitMonthsDelta.png
Then add another column
Date Range: SWITCH(TRUE()
, Benefits[Delta Profit Months] <-6, "0..6 Months"
, Benefits[Delta Profit Months] > 6 && Benefits[Delta Profit Months] <-12 , "6..12 Months"
,
"More than 12 months")
RangeOfDates.png
Then, on the ribbon, choose Table Tools and New Table
AddTable.png
Summary of Benefits: SUMMARY(Benefits,Benefits[Date Range], "No. COUNTROWS(Profits), "Sum of profit", SUM(Profits[Profit]))
Profits Summary.png

View solution in original post

1 REPLY 1
rcharara
Regular Visitor

Add a new column to your profit table

Delta Profit Months - DATEDIFF(RELATED(CustMaster[Registration Date]),Benefits[Benefit Day],MES)
ProfitMonthsDelta.png
Then add another column
Date Range: SWITCH(TRUE()
, Benefits[Delta Profit Months] <-6, "0..6 Months"
, Benefits[Delta Profit Months] > 6 && Benefits[Delta Profit Months] <-12 , "6..12 Months"
,
"More than 12 months")
RangeOfDates.png
Then, on the ribbon, choose Table Tools and New Table
AddTable.png
Summary of Benefits: SUMMARY(Benefits,Benefits[Date Range], "No. COUNTROWS(Profits), "Sum of profit", SUM(Profits[Profit]))
Profits Summary.png

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.