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.
Hi Team,
Need your help;
I want to count number of distinct months for each employee and sum them.
As per below example [Snapshot] - My DAX should return value as 7.
i.e. Distinct Sum = Distinct count of months [Month-YY] for 'XYZ' + Distinct count of month [Month-YY] for 'PQR'
= 4+3
= 7
Table Name - | Timesheet | |||
Employee_Id | Employee Name | Date | Hours | Month-YY |
1234 | XYZ | 01-Nov-18 | 23 | 11-18 |
1234 | XYZ | 13-Nov-18 | 12 | 11-18 |
1234 | XYZ | 02-Dec-18 | 34 | 12-18 |
1234 | XYZ | 12-Dec-18 | 34 | 12-18 |
1234 | XYZ | 21-Dec-18 | 34 | 12-18 |
1234 | XYZ | 26-Dec-18 | 34 | 12-18 |
1234 | XYZ | 02-Jan-19 | 24 | 01-19 |
1234 | XYZ | 21-Jan-19 | 24 | 01-19 |
1234 | XYZ | 29-Jan-19 | 24 | 01-19 |
1234 | XYZ | 02-Feb-19 | 45 | 02-19 |
1234 | XYZ | 21-Feb-19 | 45 | 02-19 |
2345 | PQR | 01-Dec-18 | 34 | 12-18 |
2345 | PQR | 19-Dec-18 | 34 | 12-18 |
2345 | PQR | 24-Dec-18 | 34 | 12-18 |
2345 | PQR | 11-Jan-19 | 32 | 01-19 |
2345 | PQR | 13-Jan-19 | 32 | 01-19 |
2345 | PQR | 15-Jan-19 | 32 | 01-19 |
2345 | PQR | 01-Feb-19 | 55 | 02-19 |
2345 | PQR | 02-Feb-19 | 55 | 02-19 |
2345 | PQR | 06-Feb-19 | 55 | 02-19 |
Distinct Count of Months by Employee | 4+3 = 7 | |||
4 Distinct months for 'XYZ' and 3 unique months for 'PQR' = 7 |
Solved! Go to Solution.
Hi @Ram_DCT
Try creating a measure like this and placing it in a Card visual, here Table1 is the table you show:
Measure = SUMX ( DISTINCT ( Table1[Employee Name] ), CALCULATE ( DISTINCTCOUNT ( Table1[Month-YY] ) ) )
Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. That allows people trying to help to readily copy the data and run a quick test, plus it increases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).
Hi @Ram_DCT
Try creating a measure like this and placing it in a Card visual, here Table1 is the table you show:
Measure = SUMX ( DISTINCT ( Table1[Employee Name] ), CALCULATE ( DISTINCTCOUNT ( Table1[Month-YY] ) ) )
Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. That allows people trying to help to readily copy the data and run a quick test, plus it increases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).
Thank you so much!! I have replaced the table [snapshot to table (Text)].
-Ram
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
101 | |
78 | |
75 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |