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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
PBI_User2300
Frequent Visitor

Measures - Last Price across different location

Hello Eveyone

 

I am trying to list the last price sold on item across different location in a table visual , and calculating the difference. But i am struggling to acheive this.

 

PBIforum.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

I am using the below measures to calculate the difference.

LPRCA = calculate(MAX('table1'[Price]),LASTDATE('table1'[Order Date]),'table1'[Location] = "A")

LPRCB = calculate(MAX('table1'[Price]),LASTDATE('table1'[Order Date]),'table1'[Location] = "B")  

 

 

Help ! Help !

 

Thanks

 

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @PBI_User2300,

   

You could create the measure below to get the last price sold on item across different location and the difference.

 

 

LPRCA = 
VAR adate =
    CALCULATE ( MAX ( 'Table'[Order Date]), 'Table'[Location] = "A")
RETURN
    CALCULATE (
        MAX ( 'Table'[Price] ),
        FILTER (
             'Table' ,
            'Table'[Location] = "A"
                && 'Table'[Order Date] = adate
        )
    )
LPRCB = 
VAR bdate =
    CALCULATE ( MAX ( 'Table'[Order Date] ), 'Table'[Location] = "B" )
RETURN
     CALCULATE (
        MAX ( 'Table'[Price] ),
        FILTER (
             'Table' ,
            'Table'[Location] = "B"
                && 'Table'[Order Date] = bdate
        )
    )

 

The picture of the result is below.

Capture.PNG

Hope it can help you!

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

10 REPLIES 10
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @PBI_User2300,

   

You could create the measure below to get the last price sold on item across different location and the difference.

 

 

LPRCA = 
VAR adate =
    CALCULATE ( MAX ( 'Table'[Order Date]), 'Table'[Location] = "A")
RETURN
    CALCULATE (
        MAX ( 'Table'[Price] ),
        FILTER (
             'Table' ,
            'Table'[Location] = "A"
                && 'Table'[Order Date] = adate
        )
    )
LPRCB = 
VAR bdate =
    CALCULATE ( MAX ( 'Table'[Order Date] ), 'Table'[Location] = "B" )
RETURN
     CALCULATE (
        MAX ( 'Table'[Price] ),
        FILTER (
             'Table' ,
            'Table'[Location] = "B"
                && 'Table'[Order Date] = bdate
        )
    )

 

The picture of the result is below.

Capture.PNG

Hope it can help you!

 

Best Regards,

Cherry

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

Hi @v-piga-msft

 

Grand Total for these measures are not correct (I noticed it today). Any idea how to resolve those ? I read lot of articles end up confused. Help ! 

 

Thanks

Hi,

 

You may refer to my solution here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur

 

I tried your solution and received this error when there is more than one Part Number 

( I added 1000 as new part number ) 

 

My bad, i should have added few Part numbers in my sample table.

Snap39.jpg

Appreciate your help.

Hi,

 

Refer to the revised file here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur

 

 i am  looking to resolve the Grand Total ( already resolved Last Price ) .. any suggestions ? 

 

Thanks again

 

Hi,

 

What answer are you expecting in the Grand Total row?  Please tell me the exact numbers that you want there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I want to see A=32 (19+13) and B=21 (11+10) in "Totals" row. I read lot of posts related to this, and it looks like a complex one to resolve, why dont it just add the data in each row displayed and show it in "Total" row :). I am sure there is a logic of how its calculated currently (showing 13 and 10 Respectively) 

 

Thanks for your help.

Hi,

 

You may refer to my solution here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks v-piga-msft. It worked.

 

Appreciate your help.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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