Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Zaky
Helper IV
Helper IV

Count Specific Year Date in a column

Hi Experts,

 

I would like to count a specific year date in a column. I'm using IF condition or statement to do that.

Let says I want to see data for 2020, 2019 and the blank data. In this case i create a column with conditions IF like below.

 

COUNTS2020 = IF(YEAR('Data2020'[Batch Return])=2020,0,1) - (Expected result to get count of data for 2020 is = 2488)

COUNTS2019 = IF(YEAR('Data2020'[Batch Return])=2019,0,1) - (Expected result to get count of data for 2019 is = 4)

and for the Blank is expected to get count = 7823

 

specific date.JPG

 

But somehow, the results doesn't get as per what i expected.

What went wrong?

 

Btw, pbix file at this link https://1drv.ms/u/s!AqKwe2kf8OBIdI-2vH30jrTDBxA?e=bpF3qC

 

Thanks

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Zaky , Try measures like

 


2020 = calculate(countrows('Data2020'), filter('Data2020', YEAR('Data2020'[Batch Return])=2020))


2019=  calculate(countrows('Data2020'), filter('Data2020', YEAR('Data2020'[Batch Return])=2019))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Zaky , Try measures like

 


2020 = calculate(countrows('Data2020'), filter('Data2020', YEAR('Data2020'[Batch Return])=2020))


2019=  calculate(countrows('Data2020'), filter('Data2020', YEAR('Data2020'[Batch Return])=2019))

Dear @amitchandak ,

Got it!.

Thank you so much bro 😅

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.