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
Vibration85
Helper II
Helper II

Value of sales based on the latest date for each country

Hi everyone 🙂

 

I have a financial table with different fields like below:

 

DateInv NumberCountryCustomer IDProduct IDQtySales
01 Feb 17Inv01000FranceA001DJAC02371226.555
05 Feb 17Inv01001FranceA003DJAC0328928.2
02 Feb 17Inv01011FranceG001FSHO0426659.1
01 Feb 17Inv01002GermanyA006DJUM01401140
03 Feb 17Inv01015GermanyL003FSHO0437937.95
04 Feb 17Inv01016GermanyM024FBOO0434928.2
05 Feb 17Inv01003GermanyB004DJUM0232912
01 Feb 17Inv01004ItalyB005DJUM0330855
03 Feb 17Inv01014ItalyK001FSHO0427684.45
02 Feb 17Inv01005ItalyC001DDRE0137865.8
02 Feb 17Inv01012CanadaH002FBOO0423627.9
01 Feb 17Inv01013CanadaJ025DJUM0122627
02 Feb 17Inv01009UKE001DDRE0330702
03 Feb 17Inv01010UKF002FSHO0425633.75
01 Feb 17Inv01008UKD006FSHO0430760.5

 

Now I gonna have something similar below that show me the value of the latest date for each country:

DateCountryLatest Sale Value
02 Feb 17Canada627.9
05 Feb 17France928.2
05 Feb 17Germany912
03 Feb 17Italy684.45
03 Feb 17UK633.75

 

I created a new table from a list of countries and I gave the ID to each country as a master country table and tried to use this formula to create a measure but I have an error on it:

 

Latest Sales Value = CALCULATE(LOOKUPVALUE(financials[ Sales],financials[Date],MAX(financials[Date])))
 
could you please let me know what should I do?
many thanks 🙂

 

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Vibration85 ,

 

You can create a NEW TABLE

 

1.jpg

 

 

Table 4 =
SUMMARIZE (
    'Table',
    'Table'[Country],
    "Latest Date", CALCULATE (
        MAX ( 'Table'[Date] )
    ),
    "Sales Value", CALCULATE (
        MAX ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date]
                = MAX ( 'Table'[Date] )
                && 'Table'[Country]
                    = MAX ( 'Table'[Country] )
        )
    )
)

 

 

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

View solution in original post

2 REPLIES 2
harshnathani
Community Champion
Community Champion

Hi @Vibration85 ,

 

You can create a NEW TABLE

 

1.jpg

 

 

Table 4 =
SUMMARIZE (
    'Table',
    'Table'[Country],
    "Latest Date", CALCULATE (
        MAX ( 'Table'[Date] )
    ),
    "Sales Value", CALCULATE (
        MAX ( 'Table'[Sales] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date]
                = MAX ( 'Table'[Date] )
                && 'Table'[Country]
                    = MAX ( 'Table'[Country] )
        )
    )
)

 

 

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

Many thanks, @harshnathani  it is working very well

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.

Top Solution Authors