Forum Discussion

Learn2Share's avatar
Learn2Share
Frequent Visitor
3 years ago
Solved

How to replace column values using DAX measure?

Hi,

 

Is it possible to change column values using dax measure (no option to modify power query/tranform data option, no option to create a calculated column as Powerbi is connected to AAS live connection)

 

Such that if I pull an attribute "Sno" on table visual &  this measure I should get output as below?

 

SnoExisting Field ValuesMeasure Output Values
11P1
22P2
33P3
4BLANKOther

 

  • Learn2Share,

     

    Try this measure:

     

    Output Value = 
    SWITCH (
        MAX ( Table1[Existing Field Values] ),
        1, "P1",
        2, "P2",
        3, "P3",
        BLANK (), "Other"
    )

     

     

6 Replies

  • Learn2Share,

     

    Try this measure:

     

    Output Value = 
    SWITCH (
        MAX ( Table1[Existing Field Values] ),
        1, "P1",
        2, "P2",
        3, "P3",
        BLANK (), "Other"
    )

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      I have a related question. I'm currently using a column name called ItemName in tables and charts, but would instead like to use a measure value ShortName:

       

      I would like to replace the ItemName value with ShortName:

      ItemNameShortName
      Product Group Alpha

      Alpha

      Product Group BetaBeta
      Product Group CharlieCharlie

       

      Here's what I tried:

       

      ShortName =
          SWITCH(
              MAX('DimCatalogItemServiceSDD'[ItemName]),
              "Product Group Alpha", "Alpha",
              "Product Group Beta", "Beta",
              "Product Group Charlie", "Charlie",
              "Nada"
          )
       
      When I add the measure to a blank table visual, all I get is "Nada".
       
      Any help would be appreciated!
      • DataInsights's avatar
        DataInsights
        Super User

        Anonymous,

         

        The simplest approach is to create a custom column (Power Query) or calculated column (DAX). If neither of these are options, temporarily change your measure to return the first SWITCH argument:

         

        MAX('DimCatalogItemServiceSDD'[ItemName])

         

        It appears there is a value in ItemName that is not in your SWITCH expression (causing it to return "Nada").