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
gsed99
Helper III
Helper III

Measure breaking with aggregation

Hello,

I am trying to apply a simple MAX calculation to a YYYYMM field, and I know the MAX value in the whole table is 201804.

When I create a measure to calculate MAX, I use this formula: =MAX('MarketingSnapshot'[DateStampMonth]).

Initially it works fine, and shows 201804, but when I add in more rows that drill down, it starts to show other values, and I want this to always show the MAX based on the whole table, not matter how deep I aggregate.

Is this possible to have it MAX over the whole 'MarketingSnapshot' table, instead of being influenced by each line?

I am using a Measure not a Column, and I could see this problem occuring if I used a Column.
Thanks,

Greg

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Try this:

 

MyMax = CALCULATE(MAX('MarketingSnapshot'[DateStampMonth]),ALL('MarketingSnapshot'))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

You cannot put a measure in a filter. See this post though on creating a calculated table with what you need then using that table value to be your filter.

 

Or, you could create a calculated column in your table using the function @Greg_Deckler gave as the column. Or create the value in Power Query as a caclulated column there and bring it into DAX that way.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Try this:

 

MyMax = CALCULATE(MAX('MarketingSnapshot'[DateStampMonth]),ALL('MarketingSnapshot'))

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you! This worked by itself, but do you know how I can put this in a Filter? I am getting the error saying too few arguments?

You cannot put a measure in a filter. See this post though on creating a calculated table with what you need then using that table value to be your filter.

 

Or, you could create a calculated column in your table using the function @Greg_Deckler gave as the column. Or create the value in Power Query as a caclulated column there and bring it into DAX that way.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Got it, thank you!

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.