Forum Discussion

PaoloCorrado's avatar
PaoloCorrado
Frequent Visitor
5 years ago
Solved

Filter Fact Value Table by multiple cluster segmentation

Hello everyone I have this problem: to each negotiation I have to assign a "score", based on the value of negotiention (ex. 150) and the date of the negotiation; if it is included in the cluster (...
  • PaulDBrown's avatar
    PaulDBrown
    4 years ago

    Thank you for the sample data. It really helps.

    Ok, here is one way.

    1) Create a Dimension table for the semesters with the function "New table" under Modeling in the ribbon using:

     

    Dim Score Period = DISTINCT('Date Table'[Sem])

     

    2) Now set up the model as follows:

    3) In the Cluster table, add a new index column using:

     

    Index =
    VAR RNK =
        RANKX (
            FILTER ( ALL ( ClusterTable ), ClusterTable[HY] = EARLIER ( ClusterTable[HY] ) ),
            [From],
            ,
            DESC
        )
    RETURN
        CALCULATE (
            RNK,
            ALLEXCEPT ( ClusterTable, ClusterTable[HY], ClusterTable[From] )
        )
    

     

     

    4) Create the following measures to calculate the score:

     

     

    Sum Result = SUM(ClusterTable[From])
    Negotiation Value = SUM(FactTable[Value Negotiention])
    Factor = SUM(ClusterTable[Score])
    Score =
    IF (
        ISINSCOPE ( 'Dim Score Period'[Sem] ),
        IF (
            ISBLANK ( [Negotiation Value] ),
            BLANK (),
            SWITCH (
                TRUE (),
                [Negotiation Value]
                    >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 1 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 1 } ),
                [Negotiation Value]
                    >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 2 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 2 } ),
                [Negotiation Value]
                    >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 3 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 3 } ),
                [Negotiation Value]
                    >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 4 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 4 } ),
                CALCULATE ( [Factor], ClusterTable[Index] IN { 5 } )
            )
        )
    )
    

     

    Now create the visual using the Semester field from the Dimension Score Period, and the rest from the fact table & add the score measure to get:

    If you prefer to have the Score as a column in the fact table, you can use:

     

    Score Column =
    SWITCH (
        TRUE (),
        FactTable[Value Negotiention]
            >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 1 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 1 } ),
        FactTable[Value Negotiention]
            >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 2 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 2 } ),
        FactTable[Value Negotiention]
            >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 3 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 3 } ),
        FactTable[Value Negotiention]
            >= CALCULATE ( [Sum Result], ClusterTable[Index] IN { 4 } ), CALCULATE ( [Factor], ClusterTable[Index] IN { 4 } ),
        CALCULATE ( [Factor], ClusterTable[Index] IN { 5 } )
    )
    

     

     

     


    Caveat: you will have to tweak the [Score] measure/column if you have more than 5 score values in a semester

    I've attached a semaple PBIX file