Forum Discussion

hitesh1607's avatar
hitesh1607
Advocate II
6 years ago
Solved

Creating Calculated Columns

I have 3 columns in the table. (1st row is the header) COLUMN A COLUMN B  COLUMN C 20 D 100 30 B 20 60 A 60 50 D 30 25 D 10 27 D 10   I need to create 5 new c...
  • v-deddai1-msft's avatar
    6 years ago

    Hi hitesh1607,

     

    >>I am trying to create a Filter for the user where he can sort a report or visual by clicking options like 'Sales less than 40% or Qty change more than 10%'.

     

    Based on your description, I suggest to create a calculated table, and then create a measure for each filter. Since I don't have your sample, I did the following based on my sample.

     

    1.Create a calculated table contains COLUMN A ,B,C as your description in your first post.

     

    Table =

    ADDCOLUMNS (

        SUMMARIZE ( 'Sales OrderDetails', 'Sales OrderDetails'[productid] ),

        "QTY", CALCULATE ( SUM ( 'Sales OrderDetails'[qty] ) ),

        "Salesamonut", 'Sales OrderDetails'[Saleamount]

    )

     

    2.Create measures for all your filter(To save time I only created three measures):

     

    A<30 = IF( MAX('Table'[QTY]) <1000,1,0)

     

     

    3.Create a table for slicer on these measures (How to use measures for slicer, please refer tohttps://www.fourmoo.com/2017/11/21/power-bi-using-a-slicer-to-show-different-measures/😞

     

     

    4.Create a measure for filter on the visual:

    Measure =

    VAR SELECTEDVALUE =

        SELECTEDVALUE ( Table2[Slicer] )

    RETURN

        SWITCH (

            TRUE (),

            SELECTEDVALUE = "A<30", [A<30],

            SELECTEDVALUE = "D", [D],

            SELECTEDVALUE = "C<50", [C<50]

        )

    5.Add the measure to the visual level filter:

     

     

     

     

    For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EU_kkYgRWzVJr3b7nm634WsB0xtNchanjgHNDOtmubxJ-g?e=drSLyC

     

    Best Regards,

    Dedmon Dai