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
Anonymous
Not applicable

Multiple conditions that have to be true at the same time on same column from a Table

Hi All,

I have a table JobStatus, with PipelineId,Status.

PipelineIdStatus
1Build
1Unit Test
1Functional Test
1Scan Status
2Build
2Unit Test
2Functional Test
2Scan Status

I am trying to get diffrent levels based on the status for each pipelineid. PipelineId is not unique.

if (Status = "Build" && Status = "Unit Test" && Status = "Functional Test" && Status = "Scan Status" Then "Level 0)

Above statement is not working when I use && (and) condition.

Not sure how to add pipelineId as filter to the above statement.

Expected result is 

PipelineIdStatusLevels
1BuildLevel 0
1Unit TestLevel 0
1Functional TestLevel 0
1Scan StatusLevel 0
2BuildLevel1
2Unit TestLevel1
2Functional TestLevel1
2Scan StatusLevel1
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. In Power query. Add Column Index Column From 1.

vyangliumsft_0-1657785686520.png

2. Create calculated column.

Rank =
RANKX(
    FILTER(ALL('Table'),
    'Table'[PipelineId]=EARLIER('Table'[PipelineId])),[Index],,ASC)
Levels =
var _build=CALCULATE(MAX('Table'[Status]),FILTER(ALL('Table'),
'Table'[PipelineId]=EARLIER('Table'[PipelineId])&&'Table'[Index]=EARLIER('Table'[Index])))
return
"Levels"&" "&
IF(
   AND( 'Table'[Rank]=1 ,'Table'[Status]="Build") ||
   AND( 'Table'[Rank]=2 ,'Table'[Status]="Unit Test")||
AND( 'Table'[Rank]=3 ,'Table'[Status]="Functional Test")||
AND( 'Table'[Rank]=4 ,'Table'[Status]="Scan Status"),
'Table'[PipelineId]-1
)

2. Result:

vyangliumsft_1-1657785686523.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. In Power query. Add Column Index Column From 1.

vyangliumsft_0-1657785686520.png

2. Create calculated column.

Rank =
RANKX(
    FILTER(ALL('Table'),
    'Table'[PipelineId]=EARLIER('Table'[PipelineId])),[Index],,ASC)
Levels =
var _build=CALCULATE(MAX('Table'[Status]),FILTER(ALL('Table'),
'Table'[PipelineId]=EARLIER('Table'[PipelineId])&&'Table'[Index]=EARLIER('Table'[Index])))
return
"Levels"&" "&
IF(
   AND( 'Table'[Rank]=1 ,'Table'[Status]="Build") ||
   AND( 'Table'[Rank]=2 ,'Table'[Status]="Unit Test")||
AND( 'Table'[Rank]=3 ,'Table'[Status]="Functional Test")||
AND( 'Table'[Rank]=4 ,'Table'[Status]="Scan Status"),
'Table'[PipelineId]-1
)

2. Result:

vyangliumsft_1-1657785686523.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but based on how the expected outcome looks like, I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Picture2.png

 

Levels CC = 
"Level " & JobStatus[PipelineId]

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi Jihwan,

 

PipelineId are alphanumeric and your code did not worked. I have diffrent status for different pipelineids.

pipelineIds are nothing but URLs. We can not append the ids. I have given you just a sample to understand the requirement. Thank you

amitchandak
Super User
Super User

@Anonymous , Try a new column like

 

new column=
Var _cnt = calculate(distinctcount(Table[Status]), filter(Table, Table[PipelineID] = earlier(Table[PipelineID) && [Status] in {"Build" ,"Unit Test" , "Functional Test" , "Scan Status" }))
return
if(_cnt =4, "Level 0", "Level 1")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi Amit,
I am getting only 2 status as Level 0 and Level1. I should get all the status based on the available status for pipelineids. Please see below new column changes and results 

BSwetha_0-1657545139701.png

 

Results


Status_Result.PNG

 

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.