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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
datatbl123
Helper I
Helper I

Change the amount of a value in a column if certain conditions are met

Hi,

 

I am looking for a DAX formula that would create a count column and would return "1" or "0.5" but only return "0.5" if the person's name in my Scheduled Person column is the same 2 days in a row (back to back days) from my Appt date column. Also the Procedure needs to be equal to A and the Center needs to be equal B.

 

Thank you,

 

2.jpg

1 ACCEPTED SOLUTION

A solution below would have better performance :

Count3 = 
VAR _patient = [Person]
VAR _date = [Date]
VAR _value =
COUNTROWS(
    FILTER(
        TableName,
        TableName[Person]=_patient
            && TableName[Center] = "B"
            && TableName[Procedure] = "A"
            && ([Date]=_date+1 || [Date]=_date-1)
    )
)
RETURN
IF(_value=1, 0.5, 1 )

 

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

hi @datatbl123 

how about more than 2 same days in a row? Or it doesnt exist?

@FreemanZ, likely not to happen

hi @datatbl123 

 

try to add a column with this:

Count2 = 
VAR _patient = [Person]
VAR _date = [Date]
VAR _value = 
AVERAGEX(
    FILTER(
        TableName,
        TableName[Person]=_patient
            && TableName[Center] = "B"
            && TableName[Procedure] = "A"
    ),
    TableName[Date]
)
RETURN
IF(_value=_date+0.5||_value=_date-0.5, 0.5,1 )

 

i tried and it worked like this:

FreemanZ_0-1671499019741.png

A solution below would have better performance :

Count3 = 
VAR _patient = [Person]
VAR _date = [Date]
VAR _value =
COUNTROWS(
    FILTER(
        TableName,
        TableName[Person]=_patient
            && TableName[Center] = "B"
            && TableName[Procedure] = "A"
            && ([Date]=_date+1 || [Date]=_date-1)
    )
)
RETURN
IF(_value=1, 0.5, 1 )

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.