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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
rido
Regular Visitor

DAX query behavior explanation

Hi,
I have a table of dates and respective values associated with the dates:

  • March 12, 2021: 22,393 unit sales
  • March 13, 2021: 21,320 unit sales
  • March 14, 2021: 21,927 unit sales
  • March 15, 2021: 21,690 unit sales

I have created a DAX formula that returns the max values among dates 12th and 14th: 

highlight2 =
    MAX(SUMX(FILTER(sales,sales[date]= DATE(2021,03,12)), sales[unit_sales]),SUMX(FILTER(sales,sales[date]= DATE(2021,03,14)), sales[unit_sales]))

Now this formula works fine and returns the highest value 22393 in a card visualization when no date field is added-
rido_2-1694954511457.png

 



But when I add the date field it returns the values for those 2 dates i.e. 12th and 14th

rido_1-1694954481592.png
 
Can someone please explain why these might be happening?

Thanks!


1 ACCEPTED SOLUTION

@rido 

When you place a column in a visual it acts as a filter. The subset of sales table that is visible in the first row is slready filtered to the date in the same row and so on. ALL removes the filter snd returns the complete table. 

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @rido 

please try

highlight2 =
MAX (
SUMX (
FILTER ( ALL ( sales ), sales[date] = DATE ( 2021, 03, 12 ) ),
sales[unit_sales]
),
SUMX (
FILTER ( ALL ( sales ), sales[date] = DATE ( 2021, 03, 14 ) ),
sales[unit_sales]
)
)

Hello,
Thank you for the response 🙂

I can see that the updated formula returns the max value among all the dates for each date but I just wanted to understand why the original formula returned the values associated with the 2 dates only when the date field had been introduced.

@rido 

When you place a column in a visual it acts as a filter. The subset of sales table that is visible in the first row is slready filtered to the date in the same row and so on. ALL removes the filter snd returns the complete table. 

Yes, that seems like it. 
Thanks a lot! 🙂

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.