The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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,
Solved! Go to Solution.
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
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
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...
(this was not requested as I mentioned "the measure "sales last year" works nicely."