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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
IamTDR
Responsive Resident
Responsive Resident

Slicer in Measure

Hi
I have created a Slicer on Book Edition. 

I then created a measure on Edition.

Selected Edition = SELECTEDVALUE(LOTSales[Edition],0)
I then created a measure for the previous edition.
Selected Edition Previous = SELECTEDVALUE(LOTSales[Edition])-1
When I drop the two measures into card visuals, the results are correct.
Yet when using the two measures to calculate the units sold by edition, the second measure defaults to the original selected measure.
Screenshot 2022-07-20 202303.png

So from this image, I selected Edition 4 (slicer) and the two card measures show the created measures are correct, 4 and 3.
Yet notice that the 'Test_Units' both have the same count for Edition number 4. I would have expected the Test One to be at 1,189 and the second to be at 4,245

Can I not use the function 'selectedvalue' in this manner?
Here are the two Test Unit measures.

TEST Units = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,[Selected Edition]))
TEST Units 2 = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,[Selected Edition Previous]))
3 REPLIES 3
amitchandak
Super User
Super User

@IamTDR , Try like

 

TEST Units = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,LOTSales[Edition] = [Selected Edition]))


TEST Units 2 = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,LOTSales[Edition] = [Selected Edition Previous]))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I just did a sample test using years instead of edition numbers.  I am getting the same incorrect results.

IamTDR_0-1658400052182.png

From my image, if I select fiscal year 2022, the cards show as expected having the year selected and the previous year.  However, note the table where it shows the correct value for the selected year's units but the previous year is now blank.
Measures used

1.

TEST CY = SELECTEDVALUE(LOTSales[Fiscal Year])
2.
TEST PY = SELECTEDVALUE(LOTSales[Fiscal Year])-1
3.
TEST CY Units = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,LOTSales[Fiscal Year]=[TEST CY]))
4.
TEST PY Units = CALCULATE(SUM(LOTSales[LOT Units]),FILTER(LOTSales,LOTSales[Fiscal Year]=[TEST PY]))

Thanks for the reply.  The first measure works as expected but the measure to calculate the previous edition units does not.  Perhaps its not possible to use a 'selectedvalue' in a measure where you minus one.  Strangely, if I place the previous edition measure into a card I get the desired result.
What I am trying to achieve, is a way for end users to select a book's edition, and compare sales with the previous edition.  I thought this method would work but the previous edition measure just will not revert to the previous edition.  Note, the field 'edition' in my LOTSales table has a whole number datatype.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.