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
LahiruFernando
Frequent Visitor

Distinct Count from filtered table by per category max value records.

Hi,
I am a novice to Power bi and expect your expertise assistance to solve below.
I have two tables, one is device data and the other is date table. Relationship between two tables is start date from device table and date from date table.

Device Table

 

rank_dateuser_idstart_dateend_datedevice
110000110/1/202010/1/2022x
210000120/2/202020/2/2022y
31000011/5/20211/6/2023x
110000220/1/202020/1/2022y
110000315/1/202015/1/2022y
210000314/05/202014/05/2022x
11000041/3/20211/3/2023x


If taking the user id 100001 to explain the logics to calculate ,

Final output should be like below table which Year and month is from date table.


(to get below table, always need to consider the record of maximum deviceTable[rank_date] for that particular user filtered first for considered date period)

1. Active users - 

distinct count of users, where deviceTable[start_date] <= endOfPeriod  && deviceTable[end_date] >= startOfPeriod
 
2. active_x_devices

distinct count of users, where deviceTable[start_date] <= endOfPeriod  && deviceTable[end_date] >= startOfPeriod, and if the deviceTable[device] = "x"

2. active_y_devices

distinct count of users, where deviceTable[start_date] <= endOfPeriod  && deviceTable[end_date] >= startOfPeriod, and if the deviceTable[device] = "y"

 

Here the user's 100001 device "y" is active after 20/2/2020 his device "x" is no more considered as active as we always take the maximum deviceTable[rank_date] per user for the considered period.

YearMonthActive Usersactive_x_devicesactive_y_devices
2020January11 
2020Ferbruay1 1
2020March1 1
2020April1 1
2020May1 1

 

 

Appreciate if anyone could help. 
Thanking in advance.
2 REPLIES 2

Hi @amitchandak ,

Thank you for your reply, of course I can apply the logic in the meterials you send to capture active and inactive users of the selected period. can you pls help me out to extend the formula to capture active x device users and active y device users as this is the critical one.

Here i need to consider the record of the user having maximum rank for that specific period.

Thank you

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.