Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
4 years ago
Solved

Multi-format numbers in the same column

Dear community very good afternoon, I have the following problem:

I have a numeric type column called Value Month, what I need is for the prensentaod value in the table to have its corresponding format. That is, for example for the first row, "Cost Reduction" I need it to be displayed in Euro Currency format, for the next row I need it to be displayed with a normal number and for the third I need it to be displayed in percentage format.

I tried to do it using conditional columns, but the display in the table makes me dirty because of the number of additional columns I need to add.

Is there a functional way that allows me to give a specific format to each value depending on the unit I need?

I also have a column called unity that I can use as a conditioner.

I remain attentive to some extra data that can serve me.

Best regards.

  • Hi

    Try like below.

    Result =
    VAR _Type =
    SELECTEDVALUE ( 'Table'[Type] )
    VAR _value =
    SUM ( 'Table'[Value] )
    RETURN
    SWITCH (
    TRUE (),
    CONTAINSSTRING ( _Type, "$" ), FORMAT ( _value, "$ #,00" ),
    CONTAINSSTRING ( _Type, "Days" ), FORMAT ( _value, "#,00" ),
    CONTAINSSTRING ( _Type, "%" ), FORMAT ( _value, "#.00 %" )
    )

    Thanks

    Hari

    Did I answer your question? Then please mark my post as the solution.
    If I helped you, click on the Thumbs Up to give Kudos.


    My Blog :: YouTube Channel :: My Linkedin


2 Replies

  • Hi

    Try like below.

    Result =
    VAR _Type =
    SELECTEDVALUE ( 'Table'[Type] )
    VAR _value =
    SUM ( 'Table'[Value] )
    RETURN
    SWITCH (
    TRUE (),
    CONTAINSSTRING ( _Type, "$" ), FORMAT ( _value, "$ #,00" ),
    CONTAINSSTRING ( _Type, "Days" ), FORMAT ( _value, "#,00" ),
    CONTAINSSTRING ( _Type, "%" ), FORMAT ( _value, "#.00 %" )
    )

    Thanks

    Hari

    Did I answer your question? Then please mark my post as the solution.
    If I helped you, click on the Thumbs Up to give Kudos.


    My Blog :: YouTube Channel :: My Linkedin


    • Anonymous's avatar
      Anonymous
      Not applicable

      tried switch function in my report page did not get the result .  used new column write the following 

      SWITCH(

          TRUE(),
          MLayout[name] = "Revenue", [Revenue],
          MLayout[name] = "Gros Profit", [GP],
          MLayout[name] = "Gros Margin",FORMAT([GP Margin],"#.00 %")
          )
       
      error message " expression that yield variant data-type can not be used to define calculated columns"