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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.