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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Roland74
Frequent Visitor

How to get the highest value on the same date

Hi,

im struggling with this case. I've got this table:

Roland74_0-1730117536049.png

(For the month June everything is the same, except the 'ResultID') 

For a selected month i need the highest ResultID, i.e. for June i want the line with ID1841, but when i select August, June is also the highest ID. I've tried several formules, now i've got:

Roland74_1-1730117789983.png

But i always get for june both lines:

Roland74_2-1730117835760.png

Trying to understand what i'm doing wrong en why?

         
1 ACCEPTED SOLUTION
Roland74
Frequent Visitor

After some trial-and-error i found the solution, which was quite simple.

MaxID_Calc2 = CALCULATE(
                MAX(factProjectPreclosureResult[ProjectPreclosureResultID]),
                ALL(factProjectPreclosureResult[ProjectPreclosureResultID]),
                ALL(factProjectPreclosureResult[PostingDateID])
                )

View solution in original post

8 REPLIES 8
Roland74
Frequent Visitor

After some trial-and-error i found the solution, which was quite simple.

MaxID_Calc2 = CALCULATE(
                MAX(factProjectPreclosureResult[ProjectPreclosureResultID]),
                ALL(factProjectPreclosureResult[ProjectPreclosureResultID]),
                ALL(factProjectPreclosureResult[PostingDateID])
                )
v-xuxinyi-msft
Community Support
Community Support

Hi @Roland74 

 

Thanks for the reply from bhanu_gautam and Greg_Deckler, please allow me to provide another insight:

 

I added a row of data to the sample data you gave, as follows:

vxuxinyimsft_0-1730281048583.png


1. Create a calculated column as a slicer table or filter

Slicer = VALUES('Table'[PostingDateID])

 

There is no relationship between the two tables.

vxuxinyimsft_1-1730281182831.png

 

2. Create a measure as follows

Measure = 
VAR _selected = SELECTEDVALUE('Slicer'[PostingDateID])
VAR _max = CALCULATE(MAX([ProjectPreclosureResultID]), FILTER(ALL('Table'), [PostingDateID] = _selected))
RETURN
IF(_selected = BLANK(), 1, IF(MAX([ProjectPreclosureResultID]) = _max, 1, 0))

 

3. Put the measure into the visual-level filters, set up show items when the value is 1.

vxuxinyimsft_2-1730281274431.png

 

Output:

 

use slicer

vxuxinyimsft_3-1730281291668.png

 

or use filter

vxuxinyimsft_4-1730281339023.png

 

Best Regards,
Yulia Xu

 

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

Hi Yulia,

Thanx for your solution. As i am on direct-query, i can't create that column.

Greg_Deckler
Super User
Super User

@Roland74 Try:

Measure = 
  VAR __Date = MAX( 'factProjectPreclosureResult'[PostingDateID] )
  VAR __Table = FILTER( ALL( 'factProjectPreclosureResult' ), [PostingDateID] = __Date )
  VAR __Result = MAXX( __Table, [ProjectPreclosureResultID] )
RETURN
  __Result


Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, 

At least i get one result with your solution, but not the right one.

In my example i show only one jobID, but my real data contains over 2.000 unique ID's.

Now it shows the highest resultID in my table, but that does not belong to the selected JobID.

(I expect 1841)

Roland74_1-1730124245734.png

 

@Roland74 I didn't know about JobID. Try this:

Measure = 
  VAR __Date = MAX( 'factProjectPreclosureResult'[PostingDateID] )
  VAR __JobID = MAX( 'factProjectPreclosureResult'[JobID] )
  VAR __Table = FILTER( ALL( 'factProjectPreclosureResult' ), [PostingDateID] = __Date && [JobID] = __JobID )
  VAR __Result = MAXX( __Table, [ProjectPreclosureResultID] )
RETURN
  __Result


Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
bhanu_gautam
Super User
Super User

@Roland74 , Create a measure to get the highest ResultID for the selected month:

DAX
MaxResultID =
CALCULATE(
MAX(Table[ResultID]),
ALLEXCEPT(Table, Table[Month])
)

 

Create a measure to check if the ResultID is the highest for the selected month:

DAX
IsMaxResultID =
IF(
Table[ResultID] = [MaxResultID],
1,
0
)

 

Add the IsMaxResultID measure to the visual level filters.
Set the filter to show only rows where IsMaxResultID is 1.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Hi Bhanu, 

Thanx for your reaction, but that doesn't seem to do the trick.

Still get the same result

Roland74_0-1730124072977.png

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.