Code Explainer | DAX

Power Query M Conditions Analysis

This analysis discusses a Power Query M script that utilizes logical operators to evaluate conditions and assign values based on specified criteria. The overview includes simplified explanations, elaboration on key concepts and an additional


Empty image or helper icon

Prompt

: if [Speed Type]=2 and [#"Speed (kbps)"]>8000 and [New Testers Status Live.Backhaul]="Microwave" or [Speed Type]=2 and [#"Speed (kbps)"]>800 and [New Testers Status Live.Backhaul]="Satellite" or [Speed Type]=2 and [#"Speed (kbps)"]>20000 and [New Testers Status Live.Backhaul]="Fiber" or  [Speed Type]=2  and [#"Speed (kbps)"]>800 and [New Testers Status Live.Backhaul]="Satellite Substitue" then 1 else 0

Answer

Code Analysis

The provided script appears to be written in Power Query M formula language, which is used for data transformation in Microsoft’s Power BI service. The code checks for multiple conditions related to values in specific fields and assigns a value based on whether these conditions are met.

Simplified Explanation

The code snippet can be broken up into five major conditions combined using and & or logical operators:

  1. The condition [Speed Type]=2 and [#"Speed (kbps)"]>8000 and [New Testers Status Live.Backhaul]="Microwave" checks whether a row's speed type is 2, speed in kbps is greater than 8000, and the backhaul status is "Microwave".
  2. The condition [Speed Type]=2 and [#"Speed (kbps)"]>800 and [New Testers Status Live.Backhaul]="Satellite" checks whether a row's speed type is 2, speed in kbps is greater than 800, and the backhaul status is "Satellite".
  3. The condition [Speed Type]=2 and [#"Speed (kbps)"]>20000 and [New Testers Status Live.Backhaul]="Fiber" checks whether a row's speed type is 2, speed in kbps is greater than 20000, and the backhaul status is "Fiber".
  4. The condition [Speed Type]=2 and [#"Speed (kbps)"]>800 and [New Testers Status Live.Backhaul]="Satellite Substitute" checks whether a row's speed type is 2, speed in kbps is greater than 800, and the backhaul status is "Satellite Substitute".

If any of these four conditions are met, the code will return 1, else it will return 0.

Elaborate on Key Concepts

The and & or logical operators are pivotal here:

  • and operator: Returns True only if both the conditions on its sides are True.
  • or operator: Returns True if at least one of the conditions on its sides is True.

Additional Examples

Consider a scenario where a student is graded. The code checks whether a student has passed ("Pass") or failed ("Fail") based on their grades in Maths and English.

if [Maths score]>35 and [English score]>35 then "Pass" else "Fail"

In this instance, the student will pass only if they have scored more than 35 in both subjects. If they fail in either subject, they will be deemed to have failed overall.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This analysis discusses a Power Query M script that utilizes logical operators to evaluate conditions and assign values based on specified criteria. The overview includes simplified explanations, elaboration on key concepts and an additional example for better understanding.