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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
svishwanathan
Helper III
Helper III

DAX for If with Filter

Hello

 

I am trying to create a calculated column that returns a yes or no based on the following conditions.

 

The max value in column A (LP Actuals'[Last Quantity Entered in past 15 days]) is 1 and also max value in column B ([Last Hours Entered in past 15 days]) is also 1 for that particular job id.

 

The dataset is a little complicated in the sense that on any particular row, we will not have value for column a and b at the same time. So essentially we need to go through all rows for that particular job and if there is a max value of 1 in column A and max value of 1 in column B, then it must return yes else no

 

IF(MAX('LP Actuals','LP Actuals'[Last Quantity Entered in past 15 days]=1 && MAX('LP Actuals','LP Actuals'[Last Hours Entered in past 15 days]=1) && 'LP Actuals'[Job Code]=EARLIER('LP Actuals'[Job Code]),"yes","no"))))

1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @svishwanathan

 

I think this might be closer (and maybe easier to read)

 

New Ccolumn = 
VAR Col1 = CALCULATE(MAX('LP Actuals'[Last Quantity Entered in past 15 days]),'LP Actuals'[Job Code] = EARLIER('LP Actuals'[Job Code]))
VAR Col2 = CALCULATE(MAX('LP Actuals'[Last Hours Entered in past 15 days]),'LP Actuals'[Job Code] = EARLIER('LP Actuals'[Job Code]))
RETURN IF(
        Col1=1 && Col2=1 , 
        --THEN--
        "Yes",
        --ELSE--
        "No"
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Hi @svishwanathan

 

I think this might be closer (and maybe easier to read)

 

New Ccolumn = 
VAR Col1 = CALCULATE(MAX('LP Actuals'[Last Quantity Entered in past 15 days]),'LP Actuals'[Job Code] = EARLIER('LP Actuals'[Job Code]))
VAR Col2 = CALCULATE(MAX('LP Actuals'[Last Hours Entered in past 15 days]),'LP Actuals'[Job Code] = EARLIER('LP Actuals'[Job Code]))
RETURN IF(
        Col1=1 && Col2=1 , 
        --THEN--
        "Yes",
        --ELSE--
        "No"
        )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Thanks Phil

 

Works well

Phil

 

Thanks for your help. I am experiencing an unusal situation. If I add any calculated column, after the one you helped me to create it says A circular dependency was detected

 

Can you make a guess on what might be happening

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.