Forum Discussion

IamTDR's avatar
IamTDR
Icon for Responsive Resident rankResponsive Resident
4 years ago

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.

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

  • 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]))

    • IamTDR's avatar
      IamTDR
      Icon for Responsive Resident rankResponsive Resident

      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.

    • IamTDR's avatar
      IamTDR
      Icon for Responsive Resident rankResponsive Resident

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

      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]))