Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to get unique values(materials)

Hi,   I'm new to PowerBi and DAX. Would like to ask for help on how to get unique count of the materials depending on the status.   Example: material 1028530, if all rows is Released then count a...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

     

    You can try formula like below:

     

    result_ = 
    VAR table_ =
        SUMMARIZE (
            YourTable,
            YourTable[Material],
            "Status",
                IF (
                    COUNTROWS ( FILTER ( YourTable, YourTable[PRStatus] = "Released" ) )
                        = COUNTROWS ( YourTable )
                        && NOT ( ISBLANK ( FIRSTNONBLANK ( YourTable[PRNo], 1 ) ) ),
                    "Released",
                    IF (
                        COUNTROWS ( FILTER ( YourTable, YourTable[PRStatus] = "Partially Released" ) ) > 0,
                        "Partially Released",
                        IF (
                            COUNTROWS ( FILTER ( YourTable, ISBLANK ( YourTable[PRNo] ) ) )
                                = COUNTROWS ( YourTable ),
                            "Unreleased",
                            BLANK ()
                        )
                    )
                )
        )
    RETURN
    if(HASONEVALUE(YourTable[PRStatus]),CALCULATE ( COUNTROWS ( table_ ) ),BLANK())

     

     

    Best Regards,
    Adamk Kong

     

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