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.
Hello PBI Community,
How do you calculate YTD counts based on two text columns (Reported By and Category) with a non-continous Date Time column in a single Table (call it Table 1)? The Reported By column contains more than >500 names with multiple entries with the same name and the Category column has ~10 different categories that also have mulitple entries. Here is an example table:
Table 1:
Date Time | Reported By | Category
2010-03-16 9:00:00 AM | John | Cat A
2010-07-16 8:00:00 AM | Mike | Cat A
2011-10-18 12:00:00 PM | Mike | Cat B
2012-12-29 9:00:00 AM | David | Cat C
The goal is to create a matrix or table on the PBI Dashboard that displays a count of each category each person had reported (that is filtered by a slicer) along with a YTD column for each category reported. For example:
Reported By | Cat A | Cat B | Cat C | Total | YTD Cat A | YTD Cat B | YTD Cat C |
Your help would be greatly appreciated!
Solved! Go to Solution.
@Anonymous,
Please firstly create the following column in your table.
Date = Table1[Date Time].[Date]
Then create a calendar table using dax below.
Date = ADDCOLUMNS(CALENDAR("2010-01-01","2013-12-31"),"Year",YEAR([Date]),"Month",MONTH([Date]))
At last, create the following measures in your table.
count_A = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat A")
count_B = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat B")
count_C = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat C")
YTD_A = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat A")
YTD_B = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat B")
YTD_C = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat C")
Another method is directly to create YTD measure using DAX: YTD = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date]). You can check more details in attached PBIX file.
Regards,
Lydia
Hi,
Here's my suggestion.
COUNT = COUNTROWS(Data)
YTD Count = CALCULATE([Count],DATESYTD(Calendar[Date]))
Hope this helps.
Hi,
Here's my suggestion.
COUNT = COUNTROWS(Data)
YTD Count = CALCULATE([Count],DATESYTD(Calendar[Date]))
Hope this helps.
@Anonymous,
Please firstly create the following column in your table.
Date = Table1[Date Time].[Date]
Then create a calendar table using dax below.
Date = ADDCOLUMNS(CALENDAR("2010-01-01","2013-12-31"),"Year",YEAR([Date]),"Month",MONTH([Date]))
At last, create the following measures in your table.
count_A = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat A")
count_B = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat B")
count_C = CALCULATE(COUNTA(Table1[Reported By]),Table1[Category]="Cat C")
YTD_A = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat A")
YTD_B = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat B")
YTD_C = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date],Table1[Category]="Cat C")
Another method is directly to create YTD measure using DAX: YTD = TOTALYTD(COUNTA(Table1[Reported By]),'Date'[Date]). You can check more details in attached PBIX file.
Regards,
Lydia
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 |
---|---|
104 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
146 | |
110 | |
107 | |
86 | |
63 |