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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
morther
Helper I
Helper I

How to count distinct Months in a column

I have a slicer in PowerBI which I can select multiple months.

 

I added a Card in PowerBI with the "Month" selected and choose (Count Distinct). When I select multiple months in the slicer, PowerBI returns the exact count of months that I selected. If I choose August, September, October, the count is "3" just as expected.

 

I need to create a Column that multiplies "130 * DISTINCTCOUNT(ImportCubicPM[Month]"

 

test = CALCULATE(130 * (
     DISTINCTCOUNT(ImportCubicPM[Month])))

 

If 2 months are selected by the slicer then the total should be 260.

 

The code above is not calculating properly.  The numbers are off a little bit.  

 

I am not sure if I should be using DISTINCTCOUNT

 

Any help would be greatly appreciated.

Thanks, Mike

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

 

What result do you get with this?

 

=130*DISTINCTCOUNT(ImportCubicPM[Month])

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

Eric_Zhang
Microsoft Employee
Microsoft Employee


@morther wrote:

I have a slicer in PowerBI which I can select multiple months.

 

I added a Card in PowerBI with the "Month" selected and choose (Count Distinct). When I select multiple months in the slicer, PowerBI returns the exact count of months that I selected. If I choose August, September, October, the count is "3" just as expected.

 

I need to create a Column that multiplies "130 * DISTINCTCOUNT(ImportCubicPM[Month]"

 

test = CALCULATE(130 * (
     DISTINCTCOUNT(ImportCubicPM[Month])))

 

If 2 months are selected by the slicer then the total should be 260.

 

The code above is not calculating properly.  The numbers are off a little bit.  

 

I am not sure if I should be using DISTINCTCOUNT

 

Any help would be greatly appreciated.

Thanks, Mike


@morther

The DAX measure shall work If it is a measure. If you actually created a "Column" in your case, try to create a measure instead. Otherwise, for further suggestion, please post more sample data of your case. Or even better you can upload the pbix file to Onedrive/Google drive and share the link.

View solution in original post

5 REPLIES 5
Eric_Zhang
Microsoft Employee
Microsoft Employee


@morther wrote:

I have a slicer in PowerBI which I can select multiple months.

 

I added a Card in PowerBI with the "Month" selected and choose (Count Distinct). When I select multiple months in the slicer, PowerBI returns the exact count of months that I selected. If I choose August, September, October, the count is "3" just as expected.

 

I need to create a Column that multiplies "130 * DISTINCTCOUNT(ImportCubicPM[Month]"

 

test = CALCULATE(130 * (
     DISTINCTCOUNT(ImportCubicPM[Month])))

 

If 2 months are selected by the slicer then the total should be 260.

 

The code above is not calculating properly.  The numbers are off a little bit.  

 

I am not sure if I should be using DISTINCTCOUNT

 

Any help would be greatly appreciated.

Thanks, Mike


@morther

The DAX measure shall work If it is a measure. If you actually created a "Column" in your case, try to create a measure instead. Otherwise, for further suggestion, please post more sample data of your case. Or even better you can upload the pbix file to Onedrive/Google drive and share the link.

Oh my goodness, I thought I had tried that yesterday but could not get it to accept the query as a measure.

 

This worked as a measure.  Thank you so much.

 

Measure = 130*DISTINCTCOUNT(ImportCubicPM[Month])

 

Hi @morther,

 

I do not know whom you are replying to but that is exactly what my suggestion was.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

 

What result do you get with this?

 

=130*DISTINCTCOUNT(ImportCubicPM[Month])

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Oh my goodness, that was my bad. This was exactly the answer.

Measure = 130*DISTINCTCOUNT(ImportCubicPM[Month])

 

I was doing this as a column, but when I changed it to a measure it worked as expected.

 

I am sorry for not giving credit where credit was due.

Mike

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors