Forum Discussion

ASchulz's avatar
ASchulz
New Member
2 years ago
Solved

How to Create a column that references another column value and NOT the data table

I have a table that I am having difficulty with. In the below table, my Locations and Plt Cap columns are not summing up because I had to use the Minimum calculation to get the value I want in the rows.

 

The code that I used for locations is this: 

LocationsForProductTypeTable = If([Product Type] = "NON-HAZ (Mezz)", 13, If([Product Type] = "NON-HAZ (A's)", 300, If([Product Type] = "Haz", 220, If([Product Type] = "Candle",5, 1))))
 
The problem is that all I want is in THIS SPECIFIC TABLE, if the Product Type is Candle, I want THIS SPECIFIC COLUMN on this table to show the value of 5. Is this something possible that I can do in Power BI?
  • The solution to this lied within adding this code as a seperate measure

    SumOfMaxLocations =
    SUMX(
        SUMMARIZE(
            Query1, [Product Type],[LocationsForProductTypeTable]
        ),[LocationsForProductTypeTable])

2 Replies

  • Martin_D's avatar
    Martin_D
    Solution Sage

    Assuming [Product Type] is a column of table MyTable, then the following measure would do the job:

    Locations = IF(SELECTEDVALUE(MyTable[Product Type])="Candle",5)

    Then add the measure to your visual.

  • The solution to this lied within adding this code as a seperate measure

    SumOfMaxLocations =
    SUMX(
        SUMMARIZE(
            Query1, [Product Type],[LocationsForProductTypeTable]
        ),[LocationsForProductTypeTable])