Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Dynamically grouping table based on user input

Say you have a table like the below where max margin and min margin represent the max and min of margin within the existing table:

CountryMarginMax MarginMin Margin
Germany508040
UK708040
USA808040
Japan558040
China408040

 

Is there a way to allow users to create some kind of grouping, like the "Region" column below, where max and min margin now calculate within the group?

CountryRegionMarginMax MarginMin Margin
Germany1507050
UK1707050
USA2808080
Japan3555540
China3405540

5 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    Max Margin=CALCULATE(MAX(Table[Margin]),ALL(Table[Country]))

    Min Margin=CALCULATE(MIN(Table[Margin]),ALL(Table[Country]))

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Anonymous 
    This is one simplified example. In real case you would need to add more conditions inside the SWITCH statement.

    Please refer to attached sample file with the proposed solution

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I probably should've been more clear, the Region grouping does not exist in the source data. They want to be able to assign the groupings on their own and then have the calculations change.

      • tamerj1's avatar
        tamerj1
        Community Champion

        Anonymous 

         Unfortunately, Power Bi does no have artificial intelligence features at least for now.