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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
SuperCal99
Helper I
Helper I

DAX - Location query

Hi,

 

I have the following sample data set:

customerIDCountyRegion
10001Greater LondonLondon
10002KentSouth East
10003SurreySouth East
10004BuckinghamshireSouth East
10005West SussexSouth East
10006OxfordshireSouth East
10007HampshireSouth East
10008Isle of WightSouth East
10009East SussexSouth East
10010BerkshireSouth East
10011HertfordshireEast of England
10012NorfolkEast of England
10013SuffolkEast of England
10014BedfordshireEast of England


I essentially want to create a table like the below, based on customer location:

County% across all counties%  within region
Greater London20%92%
Kent16%36%
Surrey14%56%


Across all counties is fine, but the % within region I have stuggling with. I get the correct values if i use region as a filter, for example, within the London region is 2 counties, Greater London and City London, which returns 99.8% and 0.2% respectively. I just want to achieve these figure without the use of a filter.

 

Thanks in advance for any guidance and help

 

Cal

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @SuperCal99 based on your sample data, create 3 measures as following, adjust your Table name for sheet1

Did I answer correctly? Kudos appreciate / accept solution.

 

#Dist cust = DISTINCTCOUNT(Sheet1[customerID])
% across all counties =
DIVIDE([#Dist cust],CALCULATE([#Dist cust],ALL()))
%  within region =
DIVIDE([#Dist cust],
    CALCULATE([#Dist cust],
    REMOVEFILTERS(Sheet1),
    VALUES(Sheet1[Region])
    )
)
 
some_bih_0-1693856848396.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

3 REPLIES 3
some_bih
Super User
Super User

Hi @SuperCal99 based on your sample data, create 3 measures as following, adjust your Table name for sheet1

Did I answer correctly? Kudos appreciate / accept solution.

 

#Dist cust = DISTINCTCOUNT(Sheet1[customerID])
% across all counties =
DIVIDE([#Dist cust],CALCULATE([#Dist cust],ALL()))
%  within region =
DIVIDE([#Dist cust],
    CALCULATE([#Dist cust],
    REMOVEFILTERS(Sheet1),
    VALUES(Sheet1[Region])
    )
)
 
some_bih_0-1693856848396.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih , many thanks for your response
I have created the measures you provided, the "%within region" measure generates the following error when adding it to the visual:

MdxScript(Model) (62.9) Calculation error in measure 'ballot' [withinregion]: The alternative result to return on divide by zero cases must be a constant numeric value

Hi @SuperCal99 measure reference should be only with [xxx] not table before it, put [withinregion].

Still, measure definition is based on another measure [#Dist cust], so process is important here, first create this measure [#Dist cust], and after that [withinregion].





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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