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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

If clause logic

Hi All,

I have an use case where i have to create 2 calculated columns named to report and not to report.Below is the logic defined for those columns.

 

To report=

Case 1:if telecom/non telecom field is telecom and both the country A and country B is "GAZ"then i have to populate the total USD Value

Case 2: if telecom/non telecom field is telecom ,  country A  is "GAZ"and country B not "GAZ"then i have to populate the 50% of total USD Value

Case 3: if telecom/non telecom field is telecom ,  country A  is not  "GAZ"and country B = "GAZ"then i have to populate the 50% of total USD Value

 

Not to report=

Case 1: if telecom/non telecom field is telecom ,  country A  is "GAZ"and country B not "GAZ"then i have to populate the 50% of total USD Value

Case 2: if telecom/non telecom field is telecom ,  country A  is not  "GAZ"and country B = "GAZ"then i have to populate the 50% of total USD Value

 

Please find the sample data and output for reference

Harika1104_0-1644853150695.png

 

 

Can someone help me to arrive this logic.

 

Thanks in advance.

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Anonymous here is how you can add, you can tweak it as you see fit

 

To Report -
VAR __telecom = Table[Telecom/NonTelecom]
VAR __countryA = Table[CountryA]
VAR __countryB = Table[CountryB]
VAR __usd = Table[USD]
RETURN
SWITCH ( TRUE(),
  __telecom = "Telecom" && __countryA = "GAZ" && __countryB = "GAZ", __usd,
  __telecom = "Telecom" && __countryA = "GAZ" && __countryB <> "GAZ", __usd * 0.5,
  __telecom = "Telecom" && __countryA <> "GAZ" && __countryB = "GAZ", __usd * 0.5,
  0 --this is else condition
)

 

similarly, you can add not to report column

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Create two calculated columns to return the value .

To report = SWITCH(TRUE(),'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]="GAZ",'Table'[USD],
                       'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]<>"GAZ",'Table'[USD]*0.5,
                       'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]<>"GAZ" && 'Table'[Country B]="GAZ",'Table'[USD]*0.5)
Not to report = SWITCH(TRUE(),'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]<>"GAZ",'Table'[USD]*0.5,
'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]<>"GAZ" && 'Table'[Country B]="GAZ",'Table'[USD]*0.5)

Then add the two columns in table .The final result is as shown :

Ailsamsft_0-1645076493157.png

I have attached my pbix file, you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

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-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Create two calculated columns to return the value .

To report = SWITCH(TRUE(),'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]="GAZ",'Table'[USD],
                       'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]<>"GAZ",'Table'[USD]*0.5,
                       'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]<>"GAZ" && 'Table'[Country B]="GAZ",'Table'[USD]*0.5)
Not to report = SWITCH(TRUE(),'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]="GAZ" && 'Table'[Country B]<>"GAZ",'Table'[USD]*0.5,
'Table'[Telecom/Non telecom]="telecom" && 'Table'[Country A]<>"GAZ" && 'Table'[Country B]="GAZ",'Table'[USD]*0.5)

Then add the two columns in table .The final result is as shown :

Ailsamsft_0-1645076493157.png

I have attached my pbix file, you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

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

parry2k
Super User
Super User

@Anonymous not sure what you mean by performance issue, it shouldn't be. What made you think it will be a performance issue?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous here is how you can add, you can tweak it as you see fit

 

To Report -
VAR __telecom = Table[Telecom/NonTelecom]
VAR __countryA = Table[CountryA]
VAR __countryB = Table[CountryB]
VAR __usd = Table[USD]
RETURN
SWITCH ( TRUE(),
  __telecom = "Telecom" && __countryA = "GAZ" && __countryB = "GAZ", __usd,
  __telecom = "Telecom" && __countryA = "GAZ" && __countryB <> "GAZ", __usd * 0.5,
  __telecom = "Telecom" && __countryA <> "GAZ" && __countryB = "GAZ", __usd * 0.5,
  0 --this is else condition
)

 

similarly, you can add not to report column

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi @parry2k ,

 

Is it possible with if clause i don't want to use variable due to some performance issue

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.