Forum Discussion

enthousiastnick's avatar
enthousiastnick
Frequent Visitor
2 years ago

create a (calculated)column based on a selection with a unique value

Hi,

I have a column 'hours' that needs to be fild with a unique value .i.e. '18' for all records, regardless the other columns.
So every record needs to be 18

And with a slicer i want to change this value from 0 to 23

 

I have searched on the internet and forums and looked at powerQuery examples  or just create columns in the model to internet but there is no simple solutions. Does anyone have a solution for this?

9 Replies

  • MNedix's avatar
    MNedix
    Solution Sage

    Hi,

    You can try the following:
    Step 1. Create a new Table and generate the desired series.

    ex: Value Selector = GENERATESERIES(0,23,1) - this will generate a series from 0 to 23 with increments of 1

    Step 2. Read the selected value with the below measure:

    Selected_Value =SELECTEDVALUE('Value selector'[Value],18) - this will read the Step 1 value BUT if nothing is selected it will return 18

    Step 3. Make the Value selector a Tile or Drop-down Slicer

    Step 4. Add the new measure to any table you want see the 2 screenshots

     

    PS: if it solved your problem please mark it as the solution, this may help others looking for the same thing

  • I did what you described:

    The selected value indeed changes, but the column test in my source table stays at the number I programmed in step 2 (in my case 1); Am I missing something?

     

     

    • MNedix's avatar
      MNedix
      Solution Sage

      What do you use for the test column? You must use a column from your dataset; in the example I made, the AccountID column is from my dataset, it is not an intermediate step.

  • In my dataset i made a new column (as you suggested) named test = [Selected_value], default = 0;
    The result is that only the default is shown, and using the slicer value stays 0

     

     

    • MNedix's avatar
      MNedix
      Solution Sage

      You misunderstood my solution. In Step 1 I said "Create a new Table" NOT a new Column. The whole example will add the value in a table visual, not in your dataset.

      In other words, with my solution you create a selectable measure that you add to a visual Table or a Table matrix together with column from your dataset.

       

      I hope it makes sense now.

      • enthousiastnick's avatar
        enthousiastnick
        Frequent Visitor

        I'm sorry I explained this not good enough. I did made a table:

        Then: measure: 

        Selected_value = SELECTEDVALUE('24_hour_tabel'[uren], 0)
        Then:
        slicer, based on table;

        Then:

        on the data-table where I need the column I add this column based on the measure:

         

        I hope I explained it right?