Forum Discussion

PrakashPalle's avatar
PrakashPalle
Helper II
2 years ago
Solved

Group by ID Skip Aggregation

Hi Power BI Experts,

How can i acheive the below expected output. Please share the dax code.

 

 

  • Could you pls provide some sample data?

     

    maybe you can this

    avg = AVERAGE('Table'[QUANTITY])
    avg2 = sumx(VALUES('Table'[ID]),[avg])
     
  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks for the reply from ryan_mayu , please allow me to provide another insight:
    Hi,PrakashPalle 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2.Then add the index column to the powerquery:

    3.Create calculated column references:

    Column = 
    VAR FIRST=CALCULATE(MIN('MAIN'[Index]),ALLEXCEPT(MAIN,'MAIN'[ID]))
    RETURN IF('MAIN'[Index]=FIRST,'MAIN'[Quanlity],BLANK())
    
    
    Column 2 = 
    VAR CI='MAIN'[ID]
    VAR RANKC=RANKX(FILTER('MAIN','MAIN'[ID]=CI),'MAIN'[Index],,ASC,Dense)
    RETURN IF(RANKC=1,'MAIN'[Quanlity],BLANK())
    

    I've given you two options that you can choose according to your needs.

     

    5.Here's my final result, which I hope meets your requirements.

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.


    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from ryan_mayu , please allow me to provide another insight:
    Hi,PrakashPalle 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2.Then add the index column to the powerquery:

    3.Create calculated column references:

    Column = 
    VAR FIRST=CALCULATE(MIN('MAIN'[Index]),ALLEXCEPT(MAIN,'MAIN'[ID]))
    RETURN IF('MAIN'[Index]=FIRST,'MAIN'[Quanlity],BLANK())
    
    
    Column 2 = 
    VAR CI='MAIN'[ID]
    VAR RANKC=RANKX(FILTER('MAIN','MAIN'[ID]=CI),'MAIN'[Index],,ASC,Dense)
    RETURN IF(RANKC=1,'MAIN'[Quanlity],BLANK())
    

    I've given you two options that you can choose according to your needs.

     

    5.Here's my final result, which I hope meets your requirements.

    Can you share sample data and sample output in tabular format if I am misunderstanding? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.


    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

  • Could you pls provide some sample data?

     

    maybe you can this

    avg = AVERAGE('Table'[QUANTITY])
    avg2 = sumx(VALUES('Table'[ID]),[avg])