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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Help Building Query

BrandModelNameModelNumberSalesPriceLogicExpected_output
AABC12325A'Price/A'Price1
BABC12330A'Price/B'Price1.2
CABC12325.4A'Price/C'Price1.016
DABC12323A'Price/D'Price0.92
EABC12326A'Price/E'Price1.04
ADEF45650A'Price/A'Price1
BDEF45648A'Price/B'Price0.96
CDEF45655A'Price/C'Price1.1
DDEF45653A'Price/D'Price1.06
EDEF45645A'Price/E'Price0.9

 

I have this sample data with me i have to calculate ratio as "A'Price/Different brand price" for that particular modelnumber as mentioned in above data.i have also shown expected output above..please help me on it..

5 REPLIES 5
v-haibl-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

Please try to create a calculated column with following expression.

 

Expected_output = 
Table1[SalesPrice]
    / CALCULATE (
        MAX ( Table1[SalesPrice] ),
        FILTER (
            ALL ( Table1 ),
            Table1[ModelName] = EARLIER ( Table1[ModelName] )
                && Table1[Brand] = "A"
        )
)

Help Building Query_1.jpg

 

Best Regards,

Herbert

Anonymous
Not applicable

BrandModelNameModelNumberSalesPriceLogicExpected_output
AABC12325A'Price/A'Price1
BABC12330A'Price/B'Price1.2
DDEF45653A'Price/D'Price1.06
EDEF45645A'Price/E'Price0.9
EABC12326A'Price/E'Price1.04
ADEF45650A'Price/A'Price1
BDEF45648A'Price/B'Price0.96
CDEF45655A'Price/C'Price1.1
CABC12325.4A'Price/C'Price1.016
DABC12323A'Price/D'Price0.92

 

whats the logic in case of same data is randomly placed as shown above..in this case EARLIER function will store previous value and that leads to wrong calculation beacuse in such case for brand "A" it should always "1" but giving different values.

colud please help me out....

 

thanks in advance Herbert.

@Anonymous

 

Using MAX() function here is just to get an aggregate value. We can also use MIN() here since there is only one A in each Model.

If the data is randomly placed, the calculated column should still works as below.

 

Help Building Query_1.jpg

 

Best Regards,

Herbert

Anonymous
Not applicable

Completely sorted.....thank you very much herbert...Smiley Happy 

it was really great help for my project....thank you so much again

 

 

Anonymous
Not applicable

Hello Herbert,

Can i know why you use MAX() function for sales price...could not collect it....

 

Thanks,

Rahul M

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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