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

DAX condition if

Hello,

 

I have many tables in power query that I don't want to merge. I'd like thanks to DAX to do somethong like this :

 

 If ('Tab1'[Type] = "Pipe")

then return 'Tab1'[thickness]  * Tab2[surface] where 'Tab1'[Size] = 'Tab2'[Size]

else return 'Tab1'[thickness]

 

Tab1
TypeSizethickness
Pipe730
Valve220
Pipe620
Valve5

20

 

Tab2
Sizenew_size
24
59
68
71


I don't know how to manage the "where 'Tab1'[Size] = 'Tab2'[Size]" part of it. Any idea ?

 

Thanks a lot !

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Assuming that you have a relationship between Data Table and Size Table.

 

1.jpg

 

 

 

2.JPG

Using MEASURES

 

Thickness*Size =

SWITCH(
TRUE(),
MAX(Data[Type]) = "Pipe" && MAX(Data[Size]) = MAX(Size[Size]), MAX(Data[thickness]) * MAx(Size[new_size]),
MAx(Data[thickness])
)

 

 

 

4.JPG

 

 

USING A CALCULATED COLUMN

 

Thickness*Size Column =

SWITCH(
TRUE(),
Data[Type] = "Pipe" && Data[Size] = RELATED(Size[Size]), Data[thickness] * RELATED (Size[new_size]),
Data[thickness]
)
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

View solution in original post

6 REPLIES 6
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Assuming that you have a relationship between Data Table and Size Table.

 

1.jpg

 

 

 

2.JPG

Using MEASURES

 

Thickness*Size =

SWITCH(
TRUE(),
MAX(Data[Type]) = "Pipe" && MAX(Data[Size]) = MAX(Size[Size]), MAX(Data[thickness]) * MAx(Size[new_size]),
MAx(Data[thickness])
)

 

 

 

4.JPG

 

 

USING A CALCULATED COLUMN

 

Thickness*Size Column =

SWITCH(
TRUE(),
Data[Type] = "Pipe" && Data[Size] = RELATED(Size[Size]), Data[thickness] * RELATED (Size[new_size]),
Data[thickness]
)
 
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 
Anonymous
Not applicable

Spoiler
Hi,

Thanks a lot ! the calculated column method works perfectly!

@Anonymous ,

 

Hahaha..

 

Loved the spoiler.

 

Happy to help.

 

Regards,

Harsh Nathani

Anonymous
Not applicable

Not done on purpose. 😅

AlB
Super User
Super User

Hi @Anonymous 

Can you provide an example based on the data, with the expected result?

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

 

Hi,

 

Thanks for answering me. I have the 2 below tables : 

 

T_Data:

T_DataT_Data

 

T_size:

T_sizeT_size

I try to do some thing like this : mesure = if('T_Data'[Type] = "Pipe",if('T_Data'[DN] = 'T_size'[DN],SUM('T_Data'[Thickness]) * SUM('T_size'[Surface pipe (m2/ml)]),0),0).

 

I'd like to have a meusure where I have sum of all pipe thickness by surface  : 'T_Data'[Thickness] * 'T_size'[Surface pipe (m2/ml)] where type = pipe for each DN corresponding surface.

 

Is that clear or do you need more details ?

 

Thanks !

 

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.

Top Solution Authors