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
mlavey24
Frequent Visitor

Display MAX value of a Measure in a card visual based on the filtered Matrix

Hi,

 

I have a matrix visual that displays the 10 closest customers (measured in Kilometers) to another customer, based on an independent slicer selection.

 

Customer NameSales AmountDistance to Selected Customer
Cust1180.3
Cust2710.4
Cust31970.57
Cust4290.87
Cust5511.03
Cust651.03
Cust7921.3
Cust81541.56
Cust9101.62
Cust10132.41

 

The distance in Kilometers is calculated with the following DAX:

 

Distinace in Kilometers:=
VAR Lat1 =
    MIN ( 'Customer X'[Lat] )
VAR Lon1 =
    MIN ( 'Customer X'[Lon] )
VAR Lat2 =
    MIN ( 'Customer Y'[Lat] )
VAR Lon2 =
    MIN ( 'Customer Y'[Lon] )
VAR P =
    DIVIDE ( PI (), 180 )
VAR A =
    0.5
        - COS ( ( Lat2 - Lat1 ) * p ) / 2
        + COS ( Lat1 * p )
            * COS ( lat2 * P )
            * (
                1
                    - COS ( ( Lon2 - Lon1 ) * p )
            ) / 2
VAR Final =
    12742 * ASIN ( ( SQRT ( A ) ) )
RETURN
    Final

Ultimately, I want a dynamic measure that would display the maximum distance from CustX to CustY (in the above example, that would mean 2.41 Km) in a card visual and I am stumped.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@mlavey24 

 

You may refer to the following post.

https://community.powerbi.com/t5/Desktop/DAX-formula-to-work-out-max-value-of-a-measure-HELP/td-p/44...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@mlavey24 

 

You may refer to the following post.

https://community.powerbi.com/t5/Desktop/DAX-formula-to-work-out-max-value-of-a-measure-HELP/td-p/44...

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.