Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Count number of computed column rows

Hi   I have a table that has its first column [Run_Date] in date format DD/MM/YY HH:MM:SS   The number of dates in this first column of the table is the result of already applied filters in power...
  • v-dineshya's avatar
    1 year ago

    Hi Anonymous ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    The .00 is happening because your computed columns are currently formatted as Decimal Numbers. You can either change their data types to Whole Number, or cast them to whole numbers in your DAX.

    Here's how to fix both the formatting and get your desired row count:

    Option 1: Fix Data Type and Use Simple COUNTROWS:

    1.Fix column types in Power BI: Go to Data view. Select [year_extracted] and [month_extracted]. Change the data type from Decimal Number to Whole Number in the ribbon.

    2.Then, create a measure like this:

    RowCount_Feb_2024 =
    CALCULATE(
    COUNTROWS('YourTable'),
    'YourTable'[year_extracted] = 2024,
    'YourTable'[month_extracted] = 2
    )

    3.Add this measure to your bar chart.

    Option 2: If You Cannot Change Column Types, Use INT to Cast:
    If changing the column type isn't working, you can cast it to whole numbers in DAX:

    RowCount_Feb_2024 =
    CALCULATE(
    COUNTROWS('YourTable'),
    INT('YourTable'[year_extracted]) = 2024,
    INT('YourTable'[month_extracted]) = 2
    )

     

    If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

    Thank you