Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Dynamic measure creating data based on column

Hi!

 

Last week I posted a problem in which I received some helpful feedback. Unfortunately I realized I needed a somewhat different solution while implementing the feedback from this forum.


My data is as follows:

 

ID

Priority

1

High

1

Medium

2

Low

3

Medium

4

High

4

Low

5

Medium

5

Low

5

High

 

 

I want to create a measure in which the ID just gets one priority. If the ID has 2 or more priorities, I want the ID to be related to the highest priority. The data should therefore look like this:

 

ID

Priority

1

High

2

Low

3

Medium

4

High

5

High

 

The feedback I received gave me a solution that created an additional column with the level of priority. The problem with this was that the data is not dynamic anymore. I want the visual that I create based on this data to be dynamic so it changes when I put filter(s). I therefore think a measure instead of a column would be more helpful.

 

Hope anyone can help 😊

  • @Janou ,

    Try a measure such as

    maxx(summarize(Table, Table[ID], "_1", calculate(count(Table[ID]), Table[Priority] ?" High"), "_2", calculate(count(Table[ID]), Table[Priority] ?" Medium"))
    switch(true(), not(isblank([_1])) , "High", not(isblank([_2])) , "Medium","Low"))

  • @Janou

    Your measure to get the desired results, you can add more priority values if necessary:

    Priority Selected = 
    
    VAR T2 = 
    GENERATE(
        VALUES(Table2[Priority]),
        FILTER( 
            UNION(
                ROW ( "Code", 1,  "Pri", "Low"),
                ROW ( "Code", 2,  "Pri", "Medium"),
                ROW ( "Code", 3,  "Pri", "High")
            )
            ,[Pri] = Table2[Priority]
        )
    )
    RETURN
    MAXX(FILTER(T2,[Code] = MAXX(T2,[Code])),[Pri])

    Fowmy_0-1598424106034.png

    ________________________

    If my answer was helpful, mark it as a solution

    Click the Thumbs-Up icon if you like this answer 🙂

    Youtube
    Linkedin



3 Replies

  • @Janou ,

    Try a measure such as

    maxx(summarize(Table, Table[ID], "_1", calculate(count(Table[ID]), Table[Priority] ?" High"), "_2", calculate(count(Table[ID]), Table[Priority] ?" Medium"))
    switch(true(), not(isblank([_1])) , "High", not(isblank([_2])) , "Medium","Low"))

  • @Janou

    Your measure to get the desired results, you can add more priority values if necessary:

    Priority Selected = 
    
    VAR T2 = 
    GENERATE(
        VALUES(Table2[Priority]),
        FILTER( 
            UNION(
                ROW ( "Code", 1,  "Pri", "Low"),
                ROW ( "Code", 2,  "Pri", "Medium"),
                ROW ( "Code", 3,  "Pri", "High")
            )
            ,[Pri] = Table2[Priority]
        )
    )
    RETURN
    MAXX(FILTER(T2,[Code] = MAXX(T2,[Code])),[Pri])

    Fowmy_0-1598424106034.png

    ________________________

    If my answer was helpful, mark it as a solution

    Click the Thumbs-Up icon if you like this answer 🙂

    Youtube
    Linkedin



  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous 

    Could you tell me if your problem has been solved? If it is, kindly Accept the helpful answer as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your problem or share me with your pbix file from your Onedrive for Business.

     

    Best Regards,

    Rico Zhou