top of page
Search
  • Writer's picturealeksvp

How can I create a measure that uses another based on the value selected of a field parameter?



So, here is the situation: a report with a bunch of visuals that uses a field parameter (let's call it FieldParameter), which groups two measures (Measure1 and Measure2). In one of the visuals, a card, I want to use another measure (Measure3), and the goal is that Measure3 returns the selected measure (Measure1 or Measure2) in FieldParameter divided by two.


But if you try to do something like this:


Measure3 = IF (SELECTEDVALUE(FieldParameter[FieldParameter]) = "Measure1", [Measure1] / 2, [Measure2] / 2)


You wil get and error when you put the measure in the visual.


So here is the trick: you can do it almost exactly like the example before, but you have to use another column (it has to be a column) in the FieldParameter table, which is a copy of the original column, like this:

CopyOfFieldParameter = [FieldParameter]


So now, Measure3 goes likes this:


Measure3 = IF (SELECTEDVALUE(FieldParameter[CopyOfFieldParameter]) = "Measure1", [Measure1] / 2, [Measure2] / 2)


As you can see bellow, if I chose Measure1, Measure3 is 50. If I chose Measure2, Measure3 is 100.



Using this, you can create a bunch o measures that depends on the measure selected in a particular field parameter.


Below is the pbix with the example.


Pretty simple, right?


10 views0 comments

Comentários


Post: Blog2_Post
bottom of page