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
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
Employee
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
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.