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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

one slicer click shows two graphs at the same time (with selected graph and year-before graphs

Hi,

 

On a page, I have four financial measures as well as a year slicer. Additionally, I succesfully created measure that automatically calculated the year before (so when I click on sales + year 2022, the measure "sales last year" works nicely.


I want to create a slicer with four options:

-revenue

-costs

-margin

-percentage

 

However, when I click for example on 'revenue' on the slicer, I want to show two line graphs at the same time:

-revenue and

-revenue last yeat

 

My financial slicer is set to 'single' option only, so a solution for multiple selections on the slicer is not needed.

 

How can I create the slicer where one click on the slicer, shows the selected graphs + the same graph the year before.

 

Thank you in advance for your help,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solved it by the follwing (1 created table + 1 created measure):

 

_CreatedTable =
ADDCOLUMNS(
DATATABLE (
"Category", STRING,
"Option", STRING,
{
{"Costs", "Year"},
{"Costs", "Year -1"},
{"Revenue", "Year"},
{"Revenue", "Year -1"}
}
)
, "Measure", [Category] & "|" & [Option]
)

--------------------------------------------

 

CreatedMeasure =
IF (
HASONEVALUE ( _Dennis[Measure] ),
SWITCH (
VALUES ( _Dennis[Measure] ),
"Costs|Year", [Costs Measure],
"Costs|Year -1", [Costs Measure-1],
"Revenue|Year", [Revenue Measure],
"Revenue|Year -1", [Revenue Measure-1]
),
BLANK ()
)

-----------------------

Afterwards, I put:
-the Year in the Line Graph X-axis
-the CreatedMeasure in the Line Graph Y-axis

-the Option column from the CreatedTable in the Legend of the Line Graph
-the category column in the slicer

That was the solution that worked for me

 

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Solved it by the follwing (1 created table + 1 created measure):

 

_CreatedTable =
ADDCOLUMNS(
DATATABLE (
"Category", STRING,
"Option", STRING,
{
{"Costs", "Year"},
{"Costs", "Year -1"},
{"Revenue", "Year"},
{"Revenue", "Year -1"}
}
)
, "Measure", [Category] & "|" & [Option]
)

--------------------------------------------

 

CreatedMeasure =
IF (
HASONEVALUE ( _Dennis[Measure] ),
SWITCH (
VALUES ( _Dennis[Measure] ),
"Costs|Year", [Costs Measure],
"Costs|Year -1", [Costs Measure-1],
"Revenue|Year", [Revenue Measure],
"Revenue|Year -1", [Revenue Measure-1]
),
BLANK ()
)

-----------------------

Afterwards, I put:
-the Year in the Line Graph X-axis
-the CreatedMeasure in the Line Graph Y-axis

-the Option column from the CreatedTable in the Legend of the Line Graph
-the category column in the slicer

That was the solution that worked for me

 

 

Anonymous
Not applicable

Hi,
I think you are looking for a measure like this:
CALCULATE(SUM(Result[sum]),FILTER(all(Result),YEAR(Result[Date])=SELECTEDVALUE(Dates[Year]) -1 && MONTH(Result[Dates])=SELECTEDVALUE(Date[Month])))
Please refer to this thread for more information: https://community.powerbi.com/t5/DAX-Commands-and-Tips/SAMEPERIODLASTYEAR-with-year-and-month-filter...

Anonymous
Not applicable

(this was not requested as I mentioned "the measure "sales last year" works nicely."

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors