Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to get the Status Column in Power Bi

Hello Super Users ,

 

Need help on the below scenario.

 

So i have 3 tables -

Employee Assigned Level

Employee NameLevels
JohnLevel 1
PeterLevel 2
JaneLevel 3
TinaLevel 4
JoeLevel 1
MikeLevel 2
LarryLevel 3
AnitaLevel 4
NimiLevel 1
ShaneLevel 2
ScottLevel 3

 

Level Master

Transaction CodeTransaction nameAssigned Level
12ABCLevel 1
13DEFLevel 1
14GHILevel 1
15JKLLevel 2
16MNQLevel 2
17PTSLevel 2
18MNSLevel 3
19YWXLevel 3
20UFOLevel 3
21JKLLevel 4
22PQRLevel 4
23TATLevel 4
26PPPLevel 5
27ABBLevel 6
28IRSLevel 5

 

Base Data

Employee NameTransaction NameTransaction Status (Yes/No)
JohnABC?
JohnDEF 
JohnGHI 
PeterMNQ 
PeterJKL 
PeterPTS 
JaneMNS 
TinaJKL 
TinaPQR 

 

First table represents employee name with the level assigned to them to complete. Second table is a level master wherein it gives details of the what the level comprises of. So to complete a particular level, employee has to complete the related transactions.

The third table is the actual base data.

 

Here is what is needed-

-> I need a status column wherein I want to know if a employee completes all the transactions in a level then should be marked Yes, otherwise should be No

 

Issue here is needless of what is assigned the employee will complete any level, we want to capture the transaction status, also the number of transaction(Count) he completed within the level assigned to them

 

I could do this in an excel using concatenate and lookup, need help in figuring out how to do this in Power BI.

 

I have been stuck on this for a while now. Your inputs would really help.

 

Thanks in Advance

 

4 Replies

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    Anonymous  a calculated column would be following

     

     

    Column =
    VAR _alreadyCompleted =
        CALCULATE (
            DISTINCTCOUNT ( Actual[Transaction Name] ),
            ALLEXCEPT ( Actual, Actual[Employee Name] )
        )
    VAR _supposedToComplete =
        CALCULATE (
            CALCULATE (
                COUNTX (
                    FILTER (
                        dimLevel,
                        dimLevel[Assigned Level]
                            = CALCULATE (
                                MAX ( dimEmployee[Levels] ),
                                CROSSFILTER ( Actual[Employee Name], dimEmployee[Employee Name], BOTH )
                            )
                    ),
                    dimLevel[Transaction name]
                )
            ),
            ALLEXCEPT ( Actual, Actual[Employee Name] )
        )
    VAR _x =
        IF ( _alreadyCompleted = _supposedToComplete, "Yes", "No" )
    RETURN
        _x
    

     

     

    and you can use the same expression in a measure as well

     

     

     

     

     

     

     

     

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank You smpa01 for your quick response.

     

    This works beautifully, But in the same table if i want to know the number of assigned transactions an employee completed v/s the actual Transaction he is supposed to complete.

     

    How should i calculate that as employee has done many transaction which may or may not be assigned to his level.

     

    Thanks again

     

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Please help on this