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
TonyGu
Helper I
Helper I

How to only return the value greater than the one in another column

I want the column to return only the datekey that is after the NP date. 

The new patient ID is returned if the Feecode is in (4 fee codes which show this is a new patient, not shown in this capture). I want to have all the datekey >= the new patient entry datekey (in this capture, it is 20210507). And those before this datekey should be 0. Am I able to do that?

 

Capture.PNG

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @TonyGu 

 

Try this code to add a new column:

NPID = 
VAR _NPD =
    CALCULATE ( MAX ( 'Table'[NPdate] ), ALLEXCEPT ( 'Table', 'Table'[PatientId] ) )
RETURN
    IF ( 'Table'[EntryDateKey] >= _NPD, 'Table'[EntryDateKey], BLANK () )

 

output:

VahidDM_0-1642544069984.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

Hi @TonyGu 

 

Try this code to add a new column:

NPID = 
VAR _NPD =
    CALCULATE ( MAX ( 'Table'[NPdate] ), ALLEXCEPT ( 'Table', 'Table'[PatientId] ) )
RETURN
    IF ( 'Table'[EntryDateKey] >= _NPD, 'Table'[EntryDateKey], BLANK () )

 

output:

VahidDM_0-1642544069984.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Thanks! This actually works!

ValtteriN
Super User
Super User

Hi,

I am not completely sure I understood what you want. What you are describing can be achieved with a simple IF clause, but if you want a list of dates (e.g. all the dates after patient admission. I would create a filter measure and use that in visuals. Ping me with @ IF this is the case).

Here is the calculated column DAX: 

Column = IF('Table (6)'[Datekey]>='Table (6)'[NP datekey],'Table (6)'[Datekey],BLANK())

end result:
ValtteriN_0-1642533312976.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!







Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for replying. I might have not explained properly what I want. Here is another capture.

The place I circled in blue is where I want to have the data. Other cell should remain blank.

 

I want to compare the 'EntryDateKey' with the 'NP Date' for each New_PatientID. For the same patient ID, if the 'EntryDateKey' is greater or equal to the 'NP Date', NPID will equal to the 'EntryDateKey', other should remain blank. Is it possible to do that?

Capture.PNG

Hi,


Here is the updated dax based on your updated problem description:

Column =
var NP_date = MAX('Table (6)'[NP datekey])
return

IF('Table (6)'[Datekey]>=NP_date,'Table (6)'[Datekey],BLANK())

New result:

ValtteriN_0-1642535395351.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

 

Sorry, but it doesn't work. I don't think MAX() is working since each PatientID has an Entry Date key and I want all the datekey greater than that.

 

I've created a simple version of what result I want. For Type A, at entry # 2, I want to have 2,3,4 to be returned in the column. As for Type B, I want to have 3 and 4 to be returned.

Capture.PNG

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.