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
learner4eva
Helper I
Helper I

Division with Lookup

Hi,

 

I am trying to add a measure that computes this formula:

(Col3 when Col2=X )divided by (Col3 when Col2 = Y) for the each unique item in Col1.

 

Example: Col A has 3 uniques --> A, B, C

For Col1 = A, New Measure = 4/8 = 0.5

For Col1 = B, New Measure = 6/3 = 2

For Col1 = C, New Measure = 3/5 = 0.6

 

Thank you for your help

 

 

Col1Col2Col3
AX4
BX6
CX3
AY8
BY3
CY5
1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @learner4eva 

 

Try this:

Measure = 
var _a=CALCULATE(SUM('Table'[Col3]),FILTER(ALLEXCEPT('Table','Table'[Col1]),'Table'[Col2]="X"))
var _b=CALCULATE(SUM('Table'[Col3]),FILTER(ALLEXCEPT('Table','Table'[Col1]),'Table'[Col2]="Y"))
return DIVIDE(_a,_b)

result:

vangzhengmsft_0-1628217907231.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @learner4eva 

 

Try this:

Measure = 
var _a=CALCULATE(SUM('Table'[Col3]),FILTER(ALLEXCEPT('Table','Table'[Col1]),'Table'[Col2]="X"))
var _b=CALCULATE(SUM('Table'[Col3]),FILTER(ALLEXCEPT('Table','Table'[Col1]),'Table'[Col2]="Y"))
return DIVIDE(_a,_b)

result:

vangzhengmsft_0-1628217907231.png

Please refer to the attachment below for details

 

 

Hope this helps.

 

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

Jihwan_Kim
Super User
Super User

Picture1.png

 

Result measure : =
VAR _x =
CALCULATE ( SUM ( Data[Col3] ), Col2[Col2] = "X" )
VAR _y =
CALCULATE ( SUM ( Data[Col3] ), Col2[Col2] = "Y" )
RETURN
IF ( HASONEVALUE ( Col1[Col1] ), DIVIDE ( _x, _y ) )

 

 

Link to the sample pbix file 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


ryan_mayu
Super User
Super User

@learner4eva 

Pls try this

Measure = sumx(FILTER('Table','Table'[Col2]="X"),'Table'[Col3]/sumx(FILTER('Table','Table'[Col2]="Y"),'Table'[Col3]))

1.PNG





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

Proud to be a Super User!




amitchandak
Super User
Super User

@learner4eva , Try a new measure like

divide(Sum(Table[Col3]), calculate(Sum(Table[Col3]), filter(allselected(Table), Table[Col1] = max(Table[Col1]) && Table[Col2] ="X")))

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.