Forum Discussion

AllanBerces's avatar
AllanBerces
Post Prodigy
4 months ago
Solved

Count base from other column

Hi good day can anyone help me on my measure, i have table and i want to count the number in phase 2 base from phase 1. Sample on my table Phase 1  month of March total count is 27 and phase for the ...
  • Lodha_Jaydeep's avatar
    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.