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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Sort filter Distinct on a table

Hi, I have this code to feed a table when toggle = true or False. The toggle name is: LbVisible.

 

If ( LbVisible.Value = false; 
Sort( Filter( INCO_REQUESTS; Status = "Submitted for Action" And Request_Type <> "NO TARIFF" And IsBlank(Email) ); Submitted_Time; Ascending ); 
Sort( Filter( INCO_REQUESTS; Status = "Submitted for Action" And IsBlank(Email) ); Submitted_Time; Ascending ) 
)

 

Now i would like to add Distinct value only, cause right now, i have duplicated rows.

How can i do that? 

Thank you

6 REPLIES 6
Vijay_A_Verma
Super User
Super User

For distinct, use below

If ( LbVisible.Value = false; 
Sort(Distinct(Filter( INCO_REQUESTS; Status = "Submitted for Action" And Request_Type <> "NO TARIFF" And IsBlank(Email) )); Submitted_Time; Ascending ); 
Sort( Distinct(Filter( INCO_REQUESTS; Status = "Submitted for Action" And IsBlank(Email) )); Submitted_Time; Ascending ) 
)

For some reason, the minute I add "Distinct", that's when I get an error. If I remove the Distinct portion of the code you gave me, it works perfectly. I will try again and get back to you, but for now, no luck.

I tried again, and when I add the Distinct code piece, I still receive the same errors:

Wilder16261626_0-1649846995041.png

I'm confused as to why this is happening.

Use this

If ( LbVisible.Value = false; 
Distinct(Sort( Filter( INCO_REQUESTS; Status = "Submitted for Action" And Request_Type <> "NO TARIFF" And IsBlank(Email) ); Submitted_Time; Ascending );"Result"); 
Distinct(Sort( Filter( INCO_REQUESTS; Status = "Submitted for Action" And IsBlank(Email) ); Submitted_Time; Ascending ) 
;"Result"))

For some reasons, i'm still having all those errors

Wilder16261626_0-1649851035184.png

 

What if i use First and groupBy to replace the Distinct?

 

Ex:

First(
    Filter(
        INCO_REQUESTS,
        Status = "Submitted for Action" And Request_Type <> "NO TARIFF" And IsBlank(Email)
    )
)

It gives me the first record only, but if i group by 2 columns value, would that also do it?

Ex: Group by "From" and "To" columns? 

 

Would i have to put my GroupBy at the beginning?

I think i was able to make it work like this:

GroupBy(
        Filter(
            INCO_REQUESTS,
            Status = "Submitted for Action" And Request_Type <> "NO TARIFF" And IsBlank(Email)
        ),
        "From",
        "To"
    )

, but i will continue to test 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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