Pseudo Code Generator

FSAMItemsDue Calculation Logic

This document outlines a structured pseudo code for calculating the count of distinct items based on specific conditions related to `FSAMIndicator` and `Due Status` using a function.


Empty image or helper icon

Prompt

FSAMItemsDue =
CALCULATE
(
DISTINCTCOUNT
(ItemEssentials[Ref No]),ItemEssentials[FSAMIndicator] =
"Yes"
,
OR
(ItemEssentials[Due Status] =
"Overdue"
,ItemEssentials[Due Status] =
"Currently Due"
)
)+
0

Answer

Pseudo Code for FSAMItemsDue Calculation

Objective

Define a logic to calculate the number of distinct items that meet specific conditions regarding the FSAMIndicator and Due Status.

Pseudo Code Structure

  1. Define the Function

    • Name the function to encapsulate the calculation.
  2. Initialize Calculation

    • Utilize a calculation mechanism (e.g., CALCULATE).
  3. Count Condition

    • Use a distinct count function on the relevant column.
  4. Incorporate Filters

    • Apply filters based on FSAMIndicator and Due Status.
  5. Output Result

    • Return the calculated count or a default value of zero if no items meet the criteria.

Pseudo Code

FUNCTION CalculateFSAMItemsDue()
    // Initialize the distinct count variable
    SET distinct_count = 0

    // Create a filter for FSAMIndicator
    SET fsam_filter = ItemEssentials[FSAMIndicator] EQUALS "Yes"

    // Create a filter for Due Status
    SET due_status_filter = (
        ItemEssentials[Due Status] EQUALS "Overdue" OR
        ItemEssentials[Due Status] EQUALS "Currently Due"
    )

    // Apply the calculation with the defined filters
    DISTINCT_ITEM_COUNT = COUNT_DISTINCT(ItemEssentials[Ref No] WHERE (fsam_filter AND due_status_filter))

    // Combine with 0
    FSAMItemsDue = DISTINCT_ITEM_COUNT + 0

    // Return the final count
    RETURN FSAMItemsDue
END FUNCTION

Explanation

  • Function Declaration: Define a function named CalculateFSAMItemsDue to encapsulate the logic.
  • Filter Creation: The fsam_filter ensures that only items with a Yes value in FSAMIndicator are considered, while due_status_filter checks if an item has a Due Status of either "Overdue" or "Currently Due".
  • Counting Logic: The COUNT_DISTINCT function counts unique reference numbers under the specified filters.
  • Output: The result adds zero to the counted value, explicitly ensuring the output type remains a number.

This structured approach provides clarity and allows for effective communication among team members during the development phase.

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 document outlines a structured pseudo code for calculating the count of distinct items based on specific conditions related to FSAMIndicator and Due Status using a function.