Forum Discussion
Count base from other column
- 4 months ago
Hi,
Thank you for sharing your data! Based on your requirement, you need to count the number of records per month separately for Phase1 and Phase2 columns. Here are the DAX measures to achieve this:
**Step 1 Create a Month column (if not already present):**
'''
Month = FORMAT('YourTable'[Phase1], "MMM")
'''**Step 2 — Measure to count Phase1 by month:**
'''
Phase1 Count =
COUNTROWS(
FILTER(
'YourTable',
MONTH('YourTable'[Phase1]) = MONTH(MIN('YourTable'[Phase1]))
)
)
'''**Step 3 Measure to count Phase2 by month:**
'''
Phase2 Count =
COUNTROWS(
FILTER(
'YourTable',
MONTH('YourTable'[Phase2]) = MONTH(MIN('YourTable'[Phase1]))
)
)
'''**Recommended Approach Using a Date/Month slicer or Matrix visual:**
Place these measures in a **Matrix visual** with Month on rows:
'''
Phase1 Count =
CALCULATETABLE(
COUNTROWS('YourTable'),
MONTH('YourTable'[Phase1]) = SELECTEDVALUE('MonthTable'[MonthNumber])
)
'''**Simplest working measure using FORMAT:**
'''
Phase1 Count =
COUNTROWS(
FILTER(
'YourTable',
FORMAT('YourTable'[Phase1], "MMM") = SELECTEDVALUE('YourTable'[Month])
)
)Phase2 Count =
COUNTROWS(
FILTER(
'YourTable',
FORMAT('YourTable'[Phase2], "MMM") = SELECTEDVALUE('YourTable'[Month])
)
)
'''This will give you the exact output shown in your sample table where March shows *27 for Phase1* and *21 for Phase2*.
Hope this helps! Let us know if you need further clarification. Please consdier this as accepted solution if helpful.
For your reference.
Step 1: I make a 'Calendar' table and add two relationships.
Calendar = CALENDARAUTO()
Step 2: I make a 'Measure' and a matrix below.
M_Count_Ph2 = CALCULATE(COUNT(DATA[Phase2]),USERELATIONSHIP('Calendar'[Date],DATA[Phase2]))