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 that to show a shapemap with saturation based on that groups and to show a color legend based on that N groups.

 

for example , my fact table have this values (district name, birth numbers):

 

torino, 3 births

cuneo, 5 births

vercelli, 15 birts

 

if user select 3 groups from slicer/filter, shapemap show 3 districts: torino, cuneo and vercelli (everyone with different colors)

if user select 2 groups from slicer/filter, shapemap show 3 districts, but 2 of theme (torino and cuneo) with the same color, ad vercelli with a second different color

 

a think i need to use ranking or percentiles but, i dont know how to do...

 

can anyone helps me ?

thanks a lot

bye

mauro

  • 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. 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.