Forum Discussion

wneiton's avatar
wneiton
Resolver I
7 years ago
Solved

Create a Slicer

Hi everyone,  I would be glad to have some help! I have 3 tables.   --Farm id_farm farm_name   --Flock id_flock id_farm   --Animal id_animal id_flock   ---Relationships--- Farm - Flo...
  • Anonymous's avatar
    Anonymous
    7 years ago

    wneiton - One possibility is to create a new Calculated Table and Calculated Column:

    1. Calculated Table for the new filter (Note that it has a buffer to go up to 1,000):

    Animal Counts = 
    var __NumberList = GENERATESERIES(1, 1000, 1)
    return 
    ADDCOLUMNS(
        __NumberList, 
        "Farm Quantity Bucket", 
        SWITCH(
            TRUE(),
            [Value] < 10, "up to 10 Animals",
            [Value] < 50, "from 10 to 50 Animals",
            [Value] < 100, "from 50 to 100 Animals",
            [Value] < 200, "from 100 to 200 Animals",
            "more that 200 Animals"
        )
    )

    2. Create a new Calculated Column on the Farm table:

    Farm Quantity = 
    var __RowCount = COUNTROWS(RELATEDTABLE(Animal))
    return MIN(__RowCount, 1000) //In case a farm has more than 1,000 animals, we still need the relationship to work.

    3. Create a Relationship between the new table and the new column.

     

    Now, you can filter on the new "Farm Quantity Bucket" to show only farms of certain sizes.

     

    Hope this helps,

    Nathan