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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Chandrashekar
Resolver III
Resolver III

Count Month for selected year in slicer

Hello,

 

Kindly help to calculate month count as below. I have two slicers one for Year and one for month but it should not effect measure.

 

DateYearMonth Count
1/1/202220222
1/2/2022202111
1/1/202120203
1/2/2021  
1/3/2021  
1/5/2021  
1/6/2021  
1/7/2021  
1/8/2021  
1/9/2021  
1/10/2021  
1/11/2021  
1/12/2021  
1/1/2020  
2/1/2020  
7/1/2020  
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Chandrashekar ,

Create a month Year column

month Year = date([Year])*100 + month([Date])

 

countx(values(Table[month Year]), [month Year] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

8 REPLIES 8
Samarth_18
Community Champion
Community Champion

Hi @Chandrashekar ,

 

Create a measure like below:-

Measure =
CALCULATE (
    COUNT ( 'Table'[Date] ),
    FILTER (
        'Table',
        YEAR ( 'Table'[Date] ) = SELECTEDVALUE ( Date[Year] )
            && MONTH ( 'Table'[Date] ) = SELECTEDVALUE ( Date[Month No] )
    )
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hello Samarth,

 

am getting wrong count. am attaching sample report. Sample Report 

Measure should not consider slicer(Month No) only it should consider slicer(year).

I want count of months for selected year.

@Chandrashekar  disable filtering of table with edit interaction and use formula like below:-

MonthCount = 
        CALCULATE(
                Count('Date'[Date]),
                FILTER(
                        'Date',
                        year('Date'[Date])=SELECTEDVALUE('Date'[Year]) 
                ))

Update file url below:-

https://we.tl/t-0YmyYsvYCs 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hello Samarth,

 

If i change month count is getting effected. even we change month values should not get effected.

Chandrashekar_0-1644573343743.png

 

use edit interaction to disable filter on card.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Hello Samarth,

 

Thanks,

 

Regards,

Chandrashekar B

amitchandak
Super User
Super User

@Chandrashekar ,

Create a month Year column

month Year = date([Year])*100 + month([Date])

 

countx(values(Table[month Year]), [month Year] )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello Amit,

 

Sorry for wrong question. I need count in Card as below. When user selected 2020 I should output as 3.

 

Chandrashekar_0-1644568310434.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.