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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
reemon007
Frequent Visitor

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 as 1 else, if has other status the count it in Partially Released, 

And only count Unreleased if all rows in PRNo is blank.

 

 

reemon007_0-1705648175753.png

 

reemon007_1-1705648292461.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @reemon007 ,

 

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())

 

vkongfanfmsft_0-1705906753219.png

 

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.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @reemon007 ,

 

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())

 

vkongfanfmsft_0-1705906753219.png

 

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.

Idrissshatila
Super User
Super User

Hello @reemon007 ,

 

create a measure as the following

DistinctCountMeasure = DISTINCTCOUNT(YourTable[Material])


Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi @Idrissshatila ,
Thank you for your time. Result is below. But the expected result is 5 Released, 3 Partial, and 1 Unreleased. 

reemon007_1-1705649325001.png

Full source.

 

reemon007_0-1705649249052.png

 

HEllo @reemon007 ,

 

but as per your data here, for example the distinct material for released are 8 not 5 as you can see.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hello @Idrissshatila 

 

This is the breakdown.

reemon007_0-1705650166961.png

Only count as Released if all status is Released and only count in Unreleased if all status is blank otherwise Partial Released.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors