Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Use selectedvalue in a measure

Hello,   I am new to PowerBI. I have a dataset, sample of it:  Version Month Value LE05 1 10 LE05 2 15 LE05 3 18 LE05 4 20 LE05 5 40 LE04 1 50 LE04 2 20 ...
  • prateekraina's avatar
    prateekraina
    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