Forum Discussion

Pfoerster's avatar
Pfoerster
Helper III
6 years ago
Solved

Create new Column based on Slicer

Hello,

in my table, I have a column called "Scenario", which allows the User to select datas for Actual, Budget, LUF.... 

Now, in order to be able to create a stacked barchard, I will create a new Scenario, which is based on a Slicer the User can use: This Slicer is the Year and the new scenario should be called "Previous" and should filter then on Scenario "Actual" and Year = Selected Year - 1.  (with that, the visual would work fine and  I can show the Previous Year, planned periods (Budget, LUF) and Actual Year). 

 

I currently have: 

A second table which is not linked to the Mastertable with all the years which are available. (=YearDimension)

A measure called "SelYear" = Selectedvalue(YearDimension[Jahr])

A measure called "PrevYear" = RawData[SelYear] - 1

 

Both measures are part of the Mastertable and when I choose in the year slicer the year 2020, my PrevYear is 2019.

 

Now, I have build a new column in the mastertable called "Scen" with

Scen = If(And('Raw Data'[Scenario] = "Actual", 'Raw Data'[Jahr]=[PrevYear]),"Previous",'Raw Data'[Scenario])

 

But this is not giving me the new Scenario "Previous" for the 2019 Actual values.... How can I create such a new Scenario based on the Year Slicer?

  • Hi Pfoerster ,

     

    First create a year table as below:

    Table 2 = VALUES('Table'[Year])

    Then create a measure as below:

    _Scen = 
    IF(MAX('Table'[Year])=SELECTEDVALUE('Table 2'[Year])-1&&MAX('Table'[Scenario])="Actual","Previous",MAX('Table'[Scenario]))

    And you will see:

    You can use the following measure to color the above value:

    _color = IF('Table'[_Scen]="Previous","#f44242","#000000")

    For the related .pbix file,pls see attached.

     

    Best Regards,
    Kelly
    Did I answer your question? Mark my post as a solution!

     

3 Replies