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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

IF Value > 0

Hi, 

 

I have the following table, I would like to get the distinct count as a query for TrackerID but when the durationconnected is greater than zero, then pick the TrackerID value for DurationConnected that is greater than zero (see second table).  Thanks for any help. 

PBI_24.PNG

 

I would like to get the following result: 

PBI_28.PNG

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

You could use DAX to change the data model.

Create a new table

Table =
FILTER (
    SUMMARIZE (
        ALL ( Sheet2 ),
        [duration],
        [id],
        "rank"RANKX (
            FILTER ( ALL ( Sheet2 ), [id] = EARLIER ( Sheet2[id] ) ),
            [duration],
            ,
            DESC,
            DENSE
        )
    ),
    [rank] = 1
)

3.png

 

Best Reagrds

Maggie

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

You could use DAX to change the data model.

Create a new table

Table =
FILTER (
    SUMMARIZE (
        ALL ( Sheet2 ),
        [duration],
        [id],
        "rank"RANKX (
            FILTER ( ALL ( Sheet2 ), [id] = EARLIER ( Sheet2[id] ) ),
            [duration],
            ,
            DESC,
            DENSE
        )
    ),
    [rank] = 1
)

3.png

 

Best Reagrds

Maggie

Maddy99
Resolver II
Resolver II

Could you open this table in Power BI Query editor?

there you can use the function 'remove duplicates'

 

remove duplicates.png

Anonymous
Not applicable

Hi Mandy, 

 

Yes, I know but when I remove the duplicates for TrackerID, it sometimes takes the 'DurationConnected' value of 0 but I want to remove duplicates for 'TrackerID' and if there is a duplicate with a value of >0, then take that value as shown in the second table. 

 

Thanks

You'll want to remove duplicates of the row, not just the column TrackerID, so make sure both columns are selected first.

The M for this is     = Table.Distinct(Source)

 

If your real data follows the pattern of your sample, you could then group by the TrackerID and MAX the DurationConnected.

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.