Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pfoerster
Helper III
Helper III

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?

1 ACCEPTED SOLUTION

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:

Annotation 2020-08-25 151350.png

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!

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Pfoerster , Not very clear .

 

Please check how measure slicer is done

 

https://radacad.com/change-the-column-or-measure-value-in-a-power-bi-visual-by-selection-of-the-slic...
https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...
https://www.youtube.com/watch?v=vlnx7QUVYME

 

for time intelligence

Power BI — YTD
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
Power BI — QTD
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
Power BI — MTD
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e

 

example

YTD  = CALCULATE([Total],DATESYTD('Date'[Date],"12/31"))
Last YTD  = CALCULATE([Total],DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year  = CALCULATE([Total],DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last to last YTD  = CALCULATE([Total],DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))

To make it clear: 

ScenarioYearTerritoryScen
Actual2020EastActual
Budget2020EastBudget
Actual2019EastPrevious
LUF2020EastLUF

 

My table is looking like this, but: Currently, I am struggeling by getting the "Previous". This should occure, when the user is selecting 2020 in a Slicer in the report. So, the column "Scen" is based on the Slicer of the Report. 

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:

Annotation 2020-08-25 151350.png

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!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.