Forum Discussion

morther's avatar
morther
Icon for Helper I rankHelper I
9 years ago
Solved

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, PowerB...
  • Ashish_Mathur's avatar
    9 years ago

    Hi,

     

    What result do you get with this?

     

    =130*DISTINCTCOUNT(ImportCubicPM[Month])

     

  • Eric_Zhang's avatar
    9 years ago

    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.