COUNTIF type formula in Powerpivot which ignores blanks

Highlander Mc

New Member
Joined
Jun 11, 2016
Messages
2
Hi

I am trying to create a COUNTIF type formula in Powerpivot and would appreciate any help on where I'm going wrong.

My data set looks something like this and I am trying to do a distinct count on the REF column based on ID and not counting blanks. I would then like to be able to have the count change if I filter my data to only show certain months


MonthIDREF1st Answer I'm Looking For2nd Answer if filtering for only Feb and March
Jan1A4
Jan2B3
Feb1C43
Feb2D32
Feb143
Mar232
Mar1E43
Mar1F43
Mar2G33

<tbody>
</tbody>

So far I managed the following formula which seems to get me half way there.(1st Answer)
=calculate(countax(distinct('TABLE'[Ref]),'TABLE'[Ref]),ALLEXCEPT('TABLE','TABLE'[id]))

However the moment I try to add another filter or calc to take the Month column into account (for 2nd Answer) I end up with errors or a count of all records.

Any help will be appreciated. I am a beginner at Dax/powerpivot so feel free to rip the formula apart and suggest a better way to approach it.

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
DAX is seemingly simple, yet it takes time to learn. Are you trying to write calculate columns here? That's what it looks like, yet that is not really how DAX is designed to work. Read this article I wrote to help Excel users understand the difference. Calculated Columns vs Measures in DAX - Excelerator BI

you should be thinking about writing measures, and then putting those measures in a pivot table to get the answer you want. The measure you need (I think) is =countrows(distinct(Table[ref]))
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top