Forum Discussion

mostof's avatar
mostof
Regular Visitor
3 years ago
Solved

Custom column based on slicer values

Hello,   I'm new to PowerBI and hope someone can help me with this elementary issue.   I have two tables: Users and Computers with a 1:N relationship. Computers table contains a "Purpose" column....
  • danextian's avatar
    danextian
    3 years ago

    The selections in the slicer doesn't affect a calculated column. As with calculated table, it gets updated only when:

    • The related tables are refreshed
    • Upon creation
    • When the formula is updated.

    Instead of calculated column use a measure.

    PC Count = 
    CALCULATE (
        COUNTROWS ( Computers ),
        FILTER ( Computers, Computers[PC_Purpose] IN VALUES ( PCPurpose[PC Purpose] ) )
    )
    

    The measure above will return the same result whether there is a relationship or not between PCPurpose and Computers tables. If there is an existing relationship, you cause simply COUNTROWS the Computers table.