powerbidaxpowerbi-desktop

Using a DAX Query to calculate a maximum value for each of my projects from two tables in a many to one relationship


I have two tables:

Table 1

PROJECT_NUMBER PROJECT_NAME
1 First Project
2 Second Project
3 Third Project

Table 2

PROJECT_NUMBER MARKET VALUE
1 Food 10
1 Retail 100
1 Fashion 200
2 Food 300
2 Retail 100
3 Fashion 500
3 Retail 10

Table 2 has a many to one relationship with Table 1, using the Project Number column.

The goal is that my final table shows me the following:

PROJECT_NUMBER PROJECT_NAME    MARKET VALUE ....
1              First Project   Fashion  200
2              Second Project  Food     300 
3              Third Project   Fashion  500

What I am getting now is a list of all the markets and a duplication of the projects for each market associated with them.

PROJECT_NUMBER PROJECT_NAME    MARKET VALUE ....
1              First Project   Food      10
1              First Project   Retail   100
1              First Project   Fashion  200
2              Second Project  Food     300
2              Second Project  Retail   100 
3              Third Project   Fashion  500
3              Third Project   Retail    10

I tried the following query, trying to replicate this post

MAX_VALUE = MAXX( FILTER('Table 2', 'Table 2'[PROJECT_NUMBER] = 'Table 1'[PROJECT_NUMBER]), 'Table 2'[VALUE])

Solution

  • In your table visual, do the following:

    1. Set the MARKET column to First

    First Market

    1. Set the VALUE column to Maximum

    Maximum Value

    Final Result:

    Final Result