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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors