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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

usage of Dax function filter

Hello,

I can't get my head around as to why the dax measure below (Number 1) doesn't work the way i want. I thought both 1 and 2 measures should behave the same way but not. Can someone explain me why the first dax measure doesn't filter to show only the last day records?

 

image.png

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Please try my measure:

test3 = 
VAR _MaxDate = MAXX(ALL('Table'),'Table'[Gaming Date])
RETURN
CALCULATE(COUNT('Table'[Gaming Date]),FILTER('Table','Table'[Gaming Date]=_MaxDate))

My Sample:

2.png

Result is as below. Test1 and test2  are measures like yours, you see test3 will get the correct result dynamiclly instead of use "Date" fucntion.

3.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

13 REPLIES 13
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Please try my measure:

test3 = 
VAR _MaxDate = MAXX(ALL('Table'),'Table'[Gaming Date])
RETURN
CALCULATE(COUNT('Table'[Gaming Date]),FILTER('Table','Table'[Gaming Date]=_MaxDate))

My Sample:

2.png

Result is as below. Test1 and test2  are measures like yours, you see test3 will get the correct result dynamiclly instead of use "Date" fucntion.

3.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Anonymous
Not applicable

Hi @v-rzhou-msft 
That is exactly what I am after . you are a legend :).

Decided not to waste my time replying until I get a proper solution as I have given enough information. Really happy that it crossed you.

Thanks again.

 

Cheers,

Deevs

parry2k
Super User
Super User

@Anonymous just asked a simple question, Read this post to get your answer quickly. It helps everyone.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous what you want to achieve? You just asked why measure 1 is different than measure 2 but you never explained what you are looking for. @pranit828 gave an explanation of the difference between measure 1 and measure 2.

 

In nutshell, @pranit828 answered your original question but if you need a further solution, you should tell what you are looking for. 

 

Well done @pranit828 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k 

 

Calm Down you might end up with high blood pressure lol.

 

@pranit828 
I want to count the records but based on a specific time period, say based on the max day or min day of the table.. If I drag the date into a table along with the measure I should only get the values based on the time period applied within the dax measure. Hope that makes sense.

 

How do you modify the below measure to achivew that. I want the table to only show the last day, not all.

Deevs_411470_2-1611121988120.png

 

 

 

 

 

 

 

 

Hi @Anonymous 

I agree with @parry2k and really hope that you use his link on how to get answers quickly.

Your initial ask and the purpose of this post is fulfilled with my first reply.
To keep the sanity of the post you already have your answer. This is going to be a new post my friend.

 

You should appreciate people trying to help here investing our personal time we can be doing something else helping other get through with work task. which demands only one thing.





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

 

lol  "myfrind"   "Your initial ask and the purpose of this post is fulfilled with my first reply."

pranit828
Community Champion
Community Champion

Hi @Anonymous 

To reply to your question about why measure1 doesn't work and measure2 works is 
Measure1 is still working on each row for max function and it sees the data in current row as max.
Now to make it work you need to let the whole calculation know that it needs to work on the entire selected table and that is what ALLSELECTED does.





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

@pranit828 

I used that but got the same results.

Deevs_411470_0-1611117982084.png

 

 

 

 

Hi @Anonymous 

Remove filter funcion from your measure





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
amitchandak
Super User
Super User

@Anonymous , In the filter one,

You have to use as the example

calculate([measure], filter(allselected(Table), [Date] =max([Date]))

 

allselected is important

Anonymous
Not applicable

@amitchandak 

 

Still the same. not filtering the max day data.

 

Deevs_411470_0-1611111303231.png

 

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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.