Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Norbertus
Helper V
Helper V

how to get the right value

hi

 

how can i realise this?

 

situation Red Value ... for date x we have a max Version with the value 2. This Version is unique so we need the value 14000

situation Green Value... for date y we have a max Version that is double. Then we need the value with the highes Time. 10000

 

This needed to be calculated for each Location

 

DateTimeVersionLocationValue
1-1-202217:001A12000
1-1-202215:002A14000
     
2-1-202216:003B9000
2-1-202217:004B10000
2-1-202215:004B11000
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Norbertus ,

Test the below measure:

test = 
VAR maxversion =
    CALCULATE (
        MAX ( 'Table'[Version] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
    )
VAR count1 =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Version] = maxversion
        )
    )
VAR maxdata =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
    )
VAR test1 =
    IF (
        count1 = 1,
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
        ),
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Date] = MAX ( 'Table'[Date] )
                    && 'Table'[Time] = maxdata
            )
        )
    )
RETURN
    IF (
        count1 = 1
            && MAX ( 'Table'[Value] ) = test1,
        "red",
        IF ( count1 > 1 && MAX ( 'Table'[Value] ) = test1, "green", BLANK () )
    )

 

vluwangmsft_0-1645695631178.png

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @Norbertus ,

Test the below measure:

test = 
VAR maxversion =
    CALCULATE (
        MAX ( 'Table'[Version] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
    )
VAR count1 =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] = MAX ( 'Table'[Date] )
                && 'Table'[Version] = maxversion
        )
    )
VAR maxdata =
    CALCULATE (
        MAX ( 'Table'[Time] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
    )
VAR test1 =
    IF (
        count1 = 1,
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER ( ALL ( 'Table' ), 'Table'[Date] = MAX ( 'Table'[Date] ) )
        ),
        CALCULATE (
            MAX ( 'Table'[Value] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Date] = MAX ( 'Table'[Date] )
                    && 'Table'[Time] = maxdata
            )
        )
    )
RETURN
    IF (
        count1 = 1
            && MAX ( 'Table'[Value] ) = test1,
        "red",
        IF ( count1 > 1 && MAX ( 'Table'[Value] ) = test1, "green", BLANK () )
    )

 

vluwangmsft_0-1645695631178.png

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

Hi @v-luwang-msft ,

 

you make my day!! 

After a small changes for my solution it works great. 

amitchandak
Super User
Super User

@Norbertus , A measure like

sumx(values(Table[Location]), calculate(max(Table[Values]), allexcept(Table, Table[Location])) )

Hi @amitchandak 

 

Thanks, but...
This solution doesn't take account of the second rule. When there are more rows of the same version by day give then the value with the higest time

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.