Forum Discussion

rufmau68_ozvvj's avatar
rufmau68_ozvvj
New Member
2 years ago
Solved

Classification measure from user selected classes number

Hi guies, im new in this community and in pbi desktop using...   i need to offer to user a slicer to select the number of classes (N) and than classify my fact table measure in N groups, to use th...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi rufmau68_ozvvj ,

     

    Since you need to group dynamically and the calculated columns can't change dynamically, we can only create a measure to implement the grouping, but due to the design, the measure can't be placed on the legend field and the shape map doesn't support conditional formatting of the colors, so we can create a filled map instead.

     

    Here are my steps you can follow as a solution.

    (1)Create tables.

    SlicerTable = GENERATESERIES(1,20,1)
    Slicer2 = GENERATESERIES(1,20,1)

    (2)Create measures.

    Measure = 
    RANKX(ALLSELECTED('Table'),[birth numbers],MAX('Table'[birth numbers]),DESC,Dense)
    Measure 3 = var a=MAXX(ALLSELECTED('Slicer2'[Value]),[Value])
    VAR B=MAXX(ALLSELECTED('Table'[district name]),[Measure])
    VAR C= ROUNDDOWN(B/a,0)
    var d= ADDCOLUMNS(ALLSELECTED(SlicerTable[Value]),"test",SWITCH(TRUE(),[Value]<a,CONCATENATEX(GENERATESERIES(([Value]-1)*C+1,[Value]*C,1),[Value],","),[Value]=a,CONCATENATEX(FILTER(ALLSELECTED('Table'),[Measure]>=([Value]-1)*C+1&&[Measure]<=b),[Measure])))
    RETURN MAXX(FILTER(d,[Value] in VALUES(SlicerTable[Value])),[test])
    Measure 4 = MAXX(FILTER(SlicerTable,CONTAINSSTRING([Measure 3],[Measure])),[Value])
    Color = SWITCH(TRUE(),  
    [Measure 4]=1,"blue",
    [Measure 4]=2,"red",
    [Measure 4]=3,"yellow")

    Best Regards,

    Neeko Tang

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