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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Measure with criteria

Hello

I want to create a measure and calculated column (later I need to make groups of these) where

If value from the same line same table of Field1 Equals value from the same line same table of Field2 then
Divide (FieldX/FieldY) Else 0 

Would it be like CALCULATE (IF (Table1[Field1] = Table1[Field2], DIVIDE (Table1[FieldX], Table1[FieldY]), 0 ) ?

 

The point is to exclude calculation in a column and measure when there is no meet criteria Table1[Field1] = Table1[Field2]

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Pbiuserr ,

I created some data:

Table1:

vyangliumsft_0-1662448099927.png

Table2:

vyangliumsft_1-1662448099928.png

Here are the steps you can follow:

1. Add Index to Table1 and Table2 in Power Query.

In Power query. Add Column – Index Column – From 1.

vyangliumsft_2-1662448099930.png

2. Create measure.

Measure_Table2 =
MAXX(FILTER(ALL(Table1),'Table1'[Index]=MAX('Table2'[Index])),[Field1])
Measure with criteria =
IF(
    MAX('Table2'[Field1])=[Measure_Table2],
    DIVIDE(MAX('Table1'[FieldX]),MAX('Table1'[FieldY]))  
    ,0)

3. Result:

vyangliumsft_3-1662448099935.png

If you need pbix, please click here.

Measure with criteria.pbix

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Pbiuserr ,

I created some data:

Table1:

vyangliumsft_0-1662448099927.png

Table2:

vyangliumsft_1-1662448099928.png

Here are the steps you can follow:

1. Add Index to Table1 and Table2 in Power Query.

In Power query. Add Column – Index Column – From 1.

vyangliumsft_2-1662448099930.png

2. Create measure.

Measure_Table2 =
MAXX(FILTER(ALL(Table1),'Table1'[Index]=MAX('Table2'[Index])),[Field1])
Measure with criteria =
IF(
    MAX('Table2'[Field1])=[Measure_Table2],
    DIVIDE(MAX('Table1'[FieldX]),MAX('Table1'[FieldY]))  
    ,0)

3. Result:

vyangliumsft_3-1662448099935.png

If you need pbix, please click here.

Measure with criteria.pbix

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

onurbmiguel_
Super User
Super User

Hi Pbiuserr

For create the calculated column you don't need the "CALCULATE". 

Try: 

IF (

   Table1[Field1] = Table1[Field2],

   DIVIDE (Table1[FieldX], Table1[FieldY]),

   0

)

 

After you can creat the measure for this new column. 

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! ;-
Best Regards
BC

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Hi

Thank you for your reply! For the measure, if the criteria is made, id like to have sum of FieldX / sum of FieldY

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.