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,
Please provide the link of the sample pbix file, like a link of dropbox / onedrive / or something else.
And then, I can try to look into it.
Thank you.
Hi Jihwan_Kim,
Unfortunately I cant supply a pbix file ( due to strict security requirements ) but it can be reconstructed by anyone doing this :
(1) Create a few filters at page level on a powerbi page ( can be anything )
(2) Go to Visualisations, Click Table symbol to create new table anywhere on the page
(3) Drag & drop in a datetime column from any existing table into the new table on the desktop and call it Run_Date
(4) Create simple computed column that has year in one column, month in another column
Thank you in advance.