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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
tolgalogy
Frequent Visitor

DAX Formula Calculates Wrong Answer

Hi,

I have two table.
First table is Location, and columns names are Region Name,Site Name and Quantity.
Other table's name is Data, and column names are Date, Site Name, and Value.

There are two Calculated Measure.
Fist calculate measure's name is WeightedAverage and is calculated by ABS ( SUMX ( 'Data', Data[Value)] * RELATED(Location[Quantity]) ) / SUMX('Data', RELATED(Location[Quantity])) )
Other Calculated Measure name is DateRangeValue, and is calculated by CALCULATE([WeightedAverage],AND (Data[Date]>=Date1,Data[Date]<=Date2)) to calculate Weighted Average between two dates.


I want to count the regions which has DayRange value is not null and higher than 2.
I create a DAX as below to calculate this, it is working but giving a wrong answer.

DISTINCTCOUNT(Location[Region],
FILTER (Location, DayRange>2 && ISBLANK(DayRange)=False))

Could you please help me to fix it?

 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@tolgalogy , Try like

countx(FILTER (Values(Location[Region]), DayRange>2 && ISBLANK(DayRange)=False),[Region])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@tolgalogy , Try like

countx(FILTER (Values(Location[Region]), DayRange>2 && ISBLANK(DayRange)=False),[Region])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak 
I used your suggestion, and transform my code as

CALCULATE(
 DISTINCTCOUNT (Location[Region],
FILTER (Values(Location[Region]),
  DayRange>2 && NOT (ISBLANK(DayRange)
 )
)
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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