The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have a five years data from 2020 to 2024.I want to count number of records in 2020, 2021,2022,2023 and 2024 separately. in power bi dax
Solved! Go to Solution.
Hi @MAP ,
you can simply use Count function
Count_2020 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2020)
Count_2021 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2021)
and so on... or
just put a slicer of year
RecordCount =
VAR SelectedYear = SELECTEDVALUE(YourTable[YearColumn])
RETURN
CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = SelectedYear)
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Record count: =
COUNTROWS(sales_fact)
Record count 2022: =
CALCULATE( [Record count:], 'calendar'[Year] = 2022)
Rocord count 2024: =
CALCULATE([Record count:], 'calendar'[Year] = 2024 )
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Record count: =
COUNTROWS(sales_fact)
Record count 2022: =
CALCULATE( [Record count:], 'calendar'[Year] = 2022)
Rocord count 2024: =
CALCULATE([Record count:], 'calendar'[Year] = 2024 )
Hi @MAP ,
you can simply use Count function
Count_2020 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2020)
Count_2021 = CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = 2021)
and so on... or
just put a slicer of year
RecordCount =
VAR SelectedYear = SELECTEDVALUE(YourTable[YearColumn])
RETURN
CALCULATE(COUNTROWS(YourTable), YEAR(YourTable[DateColumn]) = SelectedYear)