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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
GustavoVarian
Frequent Visitor

How to write this Logic in DAX

I'd like to know how to write this line bellow in DAX. I'm a beginner and I'm having a lot of problems trying to write this code in Dax to return the value I need.

(select top 1 Payor.CompanyName from Payor, PatientPayor where PatientPayor.PatientSer = pat.PatientSer and Payor.PayorSer = PatientPayor.PayorSer) as conv,

This is what I tried to do so far.

Convenio = TopN(1, VALUES(Payor[CompanyName]),PatientPayor[PatientSer]) = Filter(Patient,PatientPayor[PatientSer] = Patient[PatientSer])

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @GustavoVarian,

You can try to use the following measure formula if helps:

 

formula =
VAR currpayorSer =
    SELECTEDVALUE ( PatientPayor[PayorSer] )
VAR currPatientSer =
    SELECTEDVALUE ( PatientPayor[PatientSer] )
RETURN
    CALCULATE (
        MIN ( Payor[CompanyName] ),
        FILTER ( ALLSELECTED ( Payor ), Payor[PayorSer] = currpayorSer ),
        FILTER ( ALLSELECTED ( Patient ), Patient[PatientSer] = currPatientSer )
    )

 

If the above also doesn't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @GustavoVarian,

You can try to use the following measure formula if helps:

 

formula =
VAR currpayorSer =
    SELECTEDVALUE ( PatientPayor[PayorSer] )
VAR currPatientSer =
    SELECTEDVALUE ( PatientPayor[PatientSer] )
RETURN
    CALCULATE (
        MIN ( Payor[CompanyName] ),
        FILTER ( ALLSELECTED ( Payor ), Payor[PayorSer] = currpayorSer ),
        FILTER ( ALLSELECTED ( Patient ), Patient[PatientSer] = currPatientSer )
    )

 

If the above also doesn't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thank you all. This one did the trick! 🙂

tackytechtom
Super User
Super User

Hi @GustavoVarian ,

 

Does it work with this?

CALCULATE ( 
     MAX ( Payor[CompanyName] ),
     PatientPayor[PatientSer] = Patient[PatientSer] && Payor[PayorSer] = PatientPayor[PayorSer]
)


Does this solve your issue? 🙂 If not feel free to share some sample data and an outcome!

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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