Forum Discussion
Use selectedvalue in a measure
- 8 years ago
Hi Anonymous,
There can be many ways to achieve your result. One of them is below:
1. In Query Editor, create a column called "Version Number" which I created using Column from Example option. Let this column store the number at the end of your Version.
2. Close and apply changes. Change the data type of this column from text to whole number in Power BI Desktop.
3. Create a calculated table which will store the DISTINCT month numbers. This table will be used to for Month Number slicer.
AllMonths = DISTINCT( Table1[Month] )4. Create following measure which will hold SUM of the VALUE.
Sum Of Value = CALCULATE(SUM(Table1[Value]), FILTER(Table1, Table1[Version Number] = SELECTEDVALUE(AllMonths[Month])))
5. Now make sure the Month Number slicer is using the Month field from calculated table.
6. Use the Sum Of Value measure created in the visual where you intent to show the sum.Thats it. You have achieved what you wanted.
Here is a snapshot:
Note: Use your table names in the expressions. Table1 must be renamed to your table which contains the actual data.
Prateek Raina
Hello Prateek,
You are right. So in my example when I choose monthnumber 4, in a matrix visual it should show the version LE04 with the sum of values ALL months: 50+20+10+30+25= 135.
Hi Anonymous,
There can be many ways to achieve your result. One of them is below:
1. In Query Editor, create a column called "Version Number" which I created using Column from Example option. Let this column store the number at the end of your Version.
2. Close and apply changes. Change the data type of this column from text to whole number in Power BI Desktop.
3. Create a calculated table which will store the DISTINCT month numbers. This table will be used to for Month Number slicer.
AllMonths = DISTINCT(
Table1[Month]
)4. Create following measure which will hold SUM of the VALUE.
Sum Of Value =
CALCULATE(SUM(Table1[Value]),
FILTER(Table1,
Table1[Version Number] = SELECTEDVALUE(AllMonths[Month])))
5. Now make sure the Month Number slicer is using the Month field from calculated table.
6. Use the Sum Of Value measure created in the visual where you intent to show the sum.
Thats it. You have achieved what you wanted.
Here is a snapshot:
Note: Use your table names in the expressions. Table1 must be renamed to your table which contains the actual data.
Prateek Raina
- Anonymous8 years agoNot applicable
Hello Prateek,
First of all, thank you very much for your in depth help and the example you have built! What a great support! I tried your steps, and all seem to be good. However, I do not get the end result. Probably some basic / simple setting I forgot. But I cannot find what.
- Anonymous8 years agoNot applicable
It is working now! I did put in a relation between the 2 tables but that was not a step you told me. I deleted the connection and now it works! Thank you very very much!
- prateekraina8 years agoMemorable Member
Great !!