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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors