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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Print Status based on multiple conditions

Team, I have a table like below and I want to create a new column Latest Status with below mentioned conditions

akhil_PBI_0-1598863059036.png

Here are the conditions

Conditions:

If Name-Item is only Completed, then "Completed" and
If Name-Item is only In Progress, then left blank and
If Name-Item is both Completed and In Progress, then only for Status Completed, then Latest Status should be "Completed" and In Progress should left blank.

 

Thanks in advance!

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

Please add the following Measure:

Status New = 
    VAR _STATUS = SELECTEDVALUE('Table'[Status])
    VAR _STATUSCOUNT = 
        COUNTROWS(
            CALCULATETABLE(
                VALUES('Table'[Status]),
                ALLEXCEPT('Table','Table'[Name],'Table'[Item])
            )
        )
    RETURN 
    IF( _STATUSCOUNT=1, IF(_STATUS = "Competed", "Competed", BLANK() ) ,  
            IF( "Competed" IN CALCULATETABLE(VALUES('Table'[Status] )), "Competed", BLANK()))

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Fowmy
Super User
Super User

@Anonymous 

Please add the following Measure:

Status New = 
    VAR _STATUS = SELECTEDVALUE('Table'[Status])
    VAR _STATUSCOUNT = 
        COUNTROWS(
            CALCULATETABLE(
                VALUES('Table'[Status]),
                ALLEXCEPT('Table','Table'[Name],'Table'[Item])
            )
        )
    RETURN 
    IF( _STATUSCOUNT=1, IF(_STATUS = "Competed", "Competed", BLANK() ) ,  
            IF( "Competed" IN CALCULATETABLE(VALUES('Table'[Status] )), "Competed", BLANK()))

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy Thanks for your response. Small change in the logic.

 

Condition 1: If Nov-Item is only Completed, then it is Completed and 

Condition 2: If Nov-Item is both Completed and In Progress, we should consider the the common items as completed and unique items as In Progress. 

Ex: Sudhakar-Computer has both In Progress (50) and Completed (40). My Problem is, Out of these 50 In progress items, Completed 40 are also included. Which means 40 are common in both the status and only 10 are new/unique. In Latest Status, I want to print the common 40 as Completed and new/unique 10 are In Progress.

 

When I put this in Pie chart it should show me 2 categories (Completed and In Progress) Completed should show 40 and In progress should show 10 instead of 50. When I drill through to details page, I should see all 40 Completed Items and 10 In progress items.

akhil_PBI_0-1598873882376.png

Can you please help me with the same?

 

Thanks in advance!

amitchandak
Super User
Super User

@Anonymous , for last status you need an index column

 

then you can try a column like this

https://stackoverflow.com/questions/45715963/creating-an-index-column-for-power-bi

 

new column =
var _comp = countx(filter(table, [Name] = earlier([Name]) && [Item] = earlier([Item]) && [Status] = "Completed"),[Status])+0
var _inprogress = countx(filter(table, [Name] = earlier([Name]) && [Item] = earlier([Item]) && [Status] = "Completed"),[Status])+0
var _comp = maxx(filter(table, [Name] = earlier([Name]) && [Item] = earlier([Item])),lastnonblankvalue([idex],max(Table[Status])))+0


return
Switch( True() ,
_comp > 0 && _inprogress =0 , "Completed",
_comp > 0 && _inprogress >0 && _comp = "Completed", "Completed",
blank()
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.