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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Tito
Helper III
Helper III

Calculate number of empty in DAX

Hi everyone,

 

I would like to calculate how many names that are not in every region.

 

Best regards

Tito


Data

Data.PNG

 

zero name by region.PNG


Result:

 

zero.PNG

 

2 ACCEPTED SOLUTIONS
Rohit11
Resolver I
Resolver I

Hi @Tito 

 

Try this DAX , 

 
Count Blanks =
var _totalRegion = COUNTROWS(ALL('Table'[Name]))
return
(_totalRegion -
CALCULATE(COUNTROWS('Table'),VALUES('Table'[Region]) ))
 
Rohit11_0-1711027996399.png

 

 Thank you. 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

Hi @Tito 

Find the updated measure

Count Blanks = 
var _totalRegion = CALCULATE(DISTINCTCOUNT('Table'[Name]),ALL('Table'))
return
IF(
    HASONEVALUE('Table'[Region]),
(_totalRegion -
CALCULATE(COUNTROWS('Table'),VALUES('Table'[Region]) )),
BLANK())

View solution in original post

13 REPLIES 13
Rohit11
Resolver I
Resolver I

Hi @Tito 

 

Try this DAX , 

 
Count Blanks =
var _totalRegion = COUNTROWS(ALL('Table'[Name]))
return
(_totalRegion -
CALCULATE(COUNTROWS('Table'),VALUES('Table'[Region]) ))
 
Rohit11_0-1711027996399.png

 

 Thank you. 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Hi @Rohit11 ,

 

thank you very much! that worked.


If a name (A,B,C..) appears several times in the Name column, what should I change in Measure. Thank you!

Best regards
Tito

PowerBigginer
Helper II
Helper II

Try this
Measure = VAR NorthNotPresentCount = COUNTROWS(FILTER(ALL('Table'[Region]), 'Table'[Region] <> "North"))                       VAR WestNotPresentCount = COUNTROWS(FILTER(ALL('Table'[Region]), 'Table'[Region] <> "West"))                         VAR SouthNotPresentCount = COUNTROWS(FILTER(ALL('Table'[Region]), 'Table'[Region] <> "South"))                       VAR EastNotPresentCount = COUNTROWS(FILTER(ALL('Table'[Region]), 'Table'[Region] <> "East")) RETURN SWITCH ( TRUE (),  'Table'[Region] = "North Not Present", NorthNotPresentCount,
                                              'Table'[Region] = "West Not Present", WestNotPresentCount,
                                              'Table'[Region] = "South Not Present", SouthNotPresentCount,
                                              'Table'[Region] = "East Not Present", EastNotPresentCount )

PijushRoy
Super User
Super User

Hi @Tito 

Can you please try below DAX

 

MEASURE =
CALCULATE (
    DISTINCTCOUNT ( 'YourTable'[Name] ),
    ISBLANK ( 'YourTable'[Region] )
)

 

 


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

Thanks
Pijush
Linkedin

hi @PijushRoy ,

 

unfortunately it didn't work

 

Thanks

Tito

 

DAX1.PNG

Hi @Tito 

As your screenshot, there are no blank region
Please share your sample data in excel format, not as Screenshot 
and expected result screenshot based on sample data

Hi @PijushRoy 

 

I have 2 columns: Name and Region

 

ANorth
BWest
CSouth
DEast
ENorth
FWest
GNorth
HNorth
ISouth
KEast

 

 

 

 

Result:

zero.PNG

Hi @Tito 

Please find the PBIX file
https://drive.google.com/file/d/19hGo6zKDnV0GynZb39OcFlNo2_HCZ1RK/view?usp=sharing


Use the DAX for measure

 

MEASURE = VAR _rows = CALCULATE(COUNTROWS('Table'),ALL('Table'))
VAR _region = SELECTEDVALUE('Table'[Region])
RETURN
SWITCH(
    TRUE(),
_region = "East", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="East"),
_region = "North", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="North"),
_region = "South", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="South"),
_region = "West", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="West"))

 

 

PijushRoy_0-1711028093412.png

 


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

Thanks
Pijush
Linkedin

hi @PijushRoy 

thank you very much! that also worked.

 

Column Region was just an example and we only have 4 variables, in the real Data are several variables and you can not write all in Measure manually.

 

If a name (A,B,C..) appears several times in the Name column, what should I change in Measure. Thank you!

Best regards
Tito

Hi @Tito 

In my Measure, check the updated DAX

 

MEASURE = VAR _rows = CALCULATE(DISTINCTCOUNT('Table'[Name]),ALL('Table'))
VAR _region = SELECTEDVALUE('Table'[Region])
RETURN
SWITCH(
    TRUE(),
_region = "East", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="East"),
_region = "North", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="North"),
_region = "South", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="South"),
_region = "West", _rows - CALCULATE(COUNT('Table'[Region]),'Table'[Region]="West"))

 

 

In @Rohit11 Measure, check the updated DAX

 

Count Blanks = 
var _totalRegion = CALCULATE(DISTINCTCOUNT('Table'[Name]),ALL('Table'))
return
(_totalRegion -
CALCULATE(COUNTROWS('Table'),VALUES('Table'[Region]) ))

 

A and H respected

PijushRoy_0-1711034029639.png

Thanks, @Rohit11  for your measure


Let me know if that works for you


If your requirement is solved, please mark THIS ANSWER as SOLUTION ✔️ and help other users find the solution quickly. Please hit the Thumbs Up 👍 button if this comment helps you.

Thanks
Pijush
Linkedin

hi @PijushRoy  @Rohit11 

Thank you both. It worked great.

If it is possible, we can edit the measure so that we are no longer shown total -2. For example with Blank().

total.PNG

 

Best regards
Tito

Hi @Tito 

Find the updated measure

Count Blanks = 
var _totalRegion = CALCULATE(DISTINCTCOUNT('Table'[Name]),ALL('Table'))
return
IF(
    HASONEVALUE('Table'[Region]),
(_totalRegion -
CALCULATE(COUNTROWS('Table'),VALUES('Table'[Region]) )),
BLANK())

Hi @PijushRoy ,

 

Thank you very much! It worked really well.

 

Best regards
Tito

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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