Forum Discussion
Count number of computed column rows
- 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
Hi Anonymous ,
To count the number of rows for February 2024, you can create a measure instead of creating a calculated column using DAX as follows,
Feb2024_Count =
CALCULATE(
COUNTROWS(YourTableName),
FILTER(
YourTableName,
INT(YourTableName[year_extracted]) = 2024 &&
INT(YourTableName[month_extracted]) = 2
)
)INT(...) is used to convert decimal values like 2024.00 as integers.
Thank you for your help
Sorry, I missed out some information - I have existing page level filters already in use on the page where this table was created. So anything I create on my powerbi page will be pre-filtered.
The table I have was made by clicking "table" in Visuializations, then dragging and dropping a column of an existing dimension table into it ( the date column ).
So I do not know what this table Ive created on the desktop powerbi is actuallty called.
Is there any way to find out please? Or does it reference itself with a name of "table" or something like that ?
Sorry, I am not that experienced in powerbi....