Forum Discussion

mahenkj21's avatar
mahenkj21
Frequent Visitor
7 years ago
Solved

Need help on filter a fact table based on Product specification.

Hi, I need help on filter a fact table based on Product specification.   I have a fact file in which test characteristics are stored of products. Each product has about 30 test characteristics. I ...
  • v-juanli-msft's avatar
    v-juanli-msft
    7 years ago

    Hi mahenkj21 

    Open edit queries, select "Attribute1" and "Attribute2" in the "tblTestItems" table, select "unpivot columns"

    apply &&close

    create a new table

    link = VALUES(tblspecification[TestItem])

    then create relationship as below

    Create measures in "tblTestItems"

    Max =
    VAR max1 =
        CALCULATE (
            MAX ( tblspecification[Max] ),
            ALLSELECTED ( tblspecification ),
            FILTER ( ALL ( tblTestItems ), [Attribute] = MAX ( [Attribute] ) )
        )
    RETURN
        IF ( max1 <> BLANK (), max1, MAX ( tblTestItems[Value] ) )
    
    
    Min =
    VAR min1 =
        CALCULATE (
            MIN ( tblspecification[Min] ),
            ALLSELECTED ( tblspecification ),
            FILTER ( ALL ( tblTestItems ), [Attribute] = MAX ( [Attribute] ) )
        )
    RETURN
        IF ( min1 <> BLANK (), min1, MAX ( tblTestItems[Value] ) )
    
    
    flag1 =
    IF (
        MAX ( tblTestItems[Value] ) >= [Min]
            && MAX ( tblTestItems[Value] ) <= [Max],
        1,
        0
    )
    
    
    flag2 = SUMX(FILTER(ALL(tblTestItems),[Product]=MAX([Product])),[flag1])

     

    Please see more details in my pbix.

     

    Best Regards

    Maggie

     

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.