cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills 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

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

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors