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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Count if - Month and Year the same

Hello there,

 

I want to Count date rows, if the month and the year in the row are the same.

Is there a way to do this in DAX?

 

Beste regards

MSOMME

1 ACCEPTED SOLUTION
Jos_Woolley
Solution Sage
Solution Sage

Hi,

MyMeasure =
SUMX (
    'TABLE A',
    0
        + ( EOMONTH ( 'TABLE A'[Created], 0 ) = EOMONTH ( 'TABLE A'[finished], 0 ) )
)

Regards

View solution in original post

5 REPLIES 5
Jos_Woolley
Solution Sage
Solution Sage

Hi,

MyMeasure =
SUMX (
    'TABLE A',
    0
        + ( EOMONTH ( 'TABLE A'[Created], 0 ) = EOMONTH ( 'TABLE A'[finished], 0 ) )
)

Regards

Anonymous
Not applicable

Thanks @Jos_Woolley ,

 

This seems to work so far, but unfortunatly this measures also counts the rows where The [Created] date and the [finished] date are empty. Is there a way to only count the rows, if they both have a value?

 

Best regards 

MSOMME

Ok, then use this:

MyMeasure =
SUMX (
    'TABLE A',
    ( EOMONTH ( 'TABLE A'[Created], 0 ) = EOMONTH ( 'TABLE A'[finished], 0 ) )
        * ( 1 - ISBLANK ( 'TABLE A'[Created] ) )
)

Regards

amitchandak
Super User
Super User

@Anonymous , I am assuming you need a new column

 

New column =

var _eo = eomonth([Date], 0)

return

countx(filter(Table, eomonth([Date], 0)  =_eo), [date])

Anonymous
Not applicable

I really wasn't specific on this one. I have two dates in my table. A "created" date and a "finished" date.

I want to count those Rows, where both dates have the same Month and Year, so the EOMONTH function sure comes in handy here. 

 

I imagined something like this: COUNTROWS(TABLE A, IF(EOMONTH([Created],0)=EOMONTH([finished],0))

But I already know it isn't gonna work like that.

 

All help is very appreciated! @amitchandak 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors