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
Anonymous
Not applicable

Count distinct occurrences in last month.

I creating a scorecard for suppliers and try create 2 measures:

 

1. counting distinct occurance in last month

2 counting distinct occurances in last 6 months.

 

Dax formula will be similar just cant get it to work.

 

My table colums are: 

 

DanielWhitemore_0-1668155891374.png

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

If your datamodel does not have dim-date-column, try using some DAX functions like below.

 

 

Last six months distinct category count: =
VAR _currentmonth =
    EOMONTH ( TODAY (), 0 )
VAR _startingmonth =
    EOMONTH ( TODAY (), -6 ) + 1
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Data[Category] ),
        Data[Date] <= _currentmonth,
        Data[Date] >= _startingmonth
    )

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I tried to create a sample pbix file like below.

If your datamodel does not have dim-date-column, try using some DAX functions like below.

 

 

Last six months distinct category count: =
VAR _currentmonth =
    EOMONTH ( TODAY (), 0 )
VAR _startingmonth =
    EOMONTH ( TODAY (), -6 ) + 1
RETURN
    CALCULATE (
        DISTINCTCOUNT ( Data[Category] ),
        Data[Date] <= _currentmonth,
        Data[Date] >= _startingmonth
    )

 



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Anonymous
Not applicable

This is perfect! Thank you. 

 

Depending on the count I want to assign a score. Is is better to do it in the same measure or do you create seperate measre?

 

0 NCM = 100/100 (assigned score)
1 NCMs = 75/100
2 NCMs = 50/100
3+ NCMs = 0/100

 

Hi,

Thank you for your feedback.

I think it depends on how you want to create a visualization.

If you want to show it one by one in a card visualization, you can separately create each measure.

If you want to show it by a bar chart, for instance, 0,1,2,+3 are the component of the axis and you have to create an axis table separately, and use one measure to show them as a bar chart.

I hope this helps.

Thanks.   



Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



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.