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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
gsdrishya
New Member

How to create a measure based on a filter

Hi Team,

 

I need to create  a measure based on the client code. If the client code is A, then meausre=divide (sum(Table1[Charge] of A) , sum(Table2[Units] of A)). Can I please know how to achieve this requirement?

 

Thanks

DA

1 ACCEPTED SOLUTION
BrianConnelly
Resolver III
Resolver III

Your not giving a lot of context here, but should be something similiar to the following...

MyMeasure=
VAR chargeValue = SUMX(FILTER(ALLSELECTED(Table1),Table1[Charge] = "A"), FieldToBeSum)
VAR UnitValue = SUMX(FILTER(ALLSELECTED(Table2),Table2[Units] = "A"), FieldToBeSum)
RETURN DIVIDE(chargeValue ,UnitValue ,0)

View solution in original post

4 REPLIES 4
gsdrishya
New Member

Thanks @BrianConnelly Is there any other way to achieve this if the value of A is dynamic?

If you have a slicer to choose the dynamic value then add another variable...

MyMeasure=
VAR dynamicValue =  SELECTEDVALUE(DyanmicFieldName, DefaultValue(e.g. "A"))
VAR chargeValue = SUMX(FILTER(ALLSELECTED(Table1),Table1[Charge] = dynamicValue ), FieldToBeSum)
VAR UnitValue = SUMX(FILTER(ALLSELECTED(Table2),Table2[Units] = dynamicValue ), FieldToBeSum)
RETURN DIVIDE(chargeValue ,UnitValue ,0)

Thanks @BrianConnelly 

BrianConnelly
Resolver III
Resolver III

Your not giving a lot of context here, but should be something similiar to the following...

MyMeasure=
VAR chargeValue = SUMX(FILTER(ALLSELECTED(Table1),Table1[Charge] = "A"), FieldToBeSum)
VAR UnitValue = SUMX(FILTER(ALLSELECTED(Table2),Table2[Units] = "A"), FieldToBeSum)
RETURN DIVIDE(chargeValue ,UnitValue ,0)

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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