Forum Discussion

Khramana's avatar
Khramana
Frequent Visitor
3 years ago
Solved

Some help with right filtering needed

Hello Power BI masters! Could I kindly ask you to give some advise how to set up right filtering? I have a table that contains of several columns. Example: Ticket Number Grade Descri...
  • ChielFaber's avatar
    3 years ago

    You might try the following. I don't know if this is the best solution, but I think this might work.

     

    A little adoptation of Reza Rad's create row number per group. 

     

    The first step would be that  you follow the instruction on this blog page by Reza Rad:

     

    https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query

     

    The only difference that I would suggest is to let the index number start at 0 (although 1 would work as wel).

     

    After performing this step you get something like

     

    Ticket NumberGradeDescriptionIndex
    12345AApple0
    54321AOrange0
    54321BBanana1
    54321CPeach2
    54321CPear3

     

    After this you could do a regular group by through the UI. Choose advanced options to include all the columns. Don't perform a sum, but perform a max on the Index column.

     

    Then you get something like this:

     

    Ticket NumberGradeDescriptionIndexnumberofsubtickets
    12345AApple00
    54321AOrange03
    54321BBanana13
    54321CPeach23
    54321CPear33

     

    After this step you could add a custom column. If index = 0 and numberofsubtickets > 0 then 0 else if 

    index > 0 and numberofsubtickets > 0 then 1 else 1

    Ticket NumberGradeDescriptionIndexnumberofsubticketsNumber
    12345AApple001
    54321AOrange030
    54321BBanana131
    54321CPeach231
    54321CPear331

     

    After this you can perform a group by and sum on the number column and this will give the result your looking for.