Forum Discussion

harshadrokade's avatar
harshadrokade
Post Partisan
3 years ago
Solved

Formatting values separately in unpivot value column

Hi All,

 

I have below data-

CategoryLocationParameter1Parameter2Parameter3Parameter4Parameter5Parameter6
C1L1255%542%2419%
C2L2488%333%998%
C3L3913%131%6315%
C4L4775%322%1920%
C5L5373%721%6334%
C6L6575%351%287%
C7L7193%481%9215%
C8L8718%962%3310%
C9L9964%231%296%
C10L10364%691%466%

 

As I want to create a column chart along with a parameter selection filter, I unpivot the data as below.

 

 

I have generated the column visual as below. The problem is since I unpivot the columns, the absolute value columns (Parameter1, Parameter3, Parameter5) & % columns (Parameter2, Parameter4, Parameter6) got into a single value column removing the % sign from % value fields.  Now when I select a parameter with % values, the chart shows % values in decimals. How can I bring the % format for the % values in this case? 

 

 

 

7 Replies

    • harshadrokade's avatar
      harshadrokade
      Post Partisan

      Thanks a ton MFelix . I see you could keep the % formatting of the column as Text in the power query from the first step itself. In my case, when I upload my data in Power bi & see it in Power query, the % columns automatically get converted into decimals & so the % icon doesn't remain with them. That's why I also cant use Text Dax to find the columns having % in them. 

       

       

      In my case, when I unpivot the parameter columns, the % format goes away & it becomes decimals.. As the format changes for % values, my Fax new column cant identify the % columns as those are not Text columns with % in them. 

      • MFelix's avatar
        MFelix
        Super User

        Hi harshadrokade,

         

        After the unpivoting see if the step for the changed type is added if yes delete that step and add the custom column then redo the formatting. 

  • Thanks MFelix This was very very helpful & I will use the same. Just one query- I have huge around 100 parameters which will be in % format. Will DAX format formula accept so many field names into the same? 

     

    But this was really good. Made my day 🙂 Thanks again

    • MFelix's avatar
      MFelix
      Super User

      Hi harshadrokade,

       

      Power BI will accept, however being so many cases the best option is to create a new column on your model that defines in text the values for each format and then use that column on format in this case I have created a step on power query befor making the type format:

       

      Has you can see if I have percentages then I do the percentage format.

       

      Then I change the format dax to:

      IF( HASONEVALUE('Table'[Attribute]), SELECTEDVALUE('Table'[Formatting String]))

       

      Result below:

       

      No need to write any of your formula, in the future if you want to update the syntax you just need to change it in Power Query for example:

      No I have two decimals without the need to change all the formula.

       

      PBIX attach.