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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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] )

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] )

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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