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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bvilten
Helper III
Helper III

ARGHH A.K.A. DAX, need help creating DAX from pseudo code

Hello All,

 

I have reached the end of my capabilities it seems. I have an urgent request for help in creating DAX. In essance the user specifies a date range and if the contract is in that date range add that contract to the display and show Contract Name, Total Price, Annual Cost. I have thought about making a list of months/years betwen FromDate and ToDate and another list of months/years between RequestedStartDate (RSD) and RequestedEndDate(RED) and using some sort of IF is in function, but haven't gotten very far down that road yet.

 

The logic I am trying to create in DAX is as follows:

 

Variables input by user

(not really sure how to capture this either, I have tried using the Date Range slicer based on a date table not connected to anyother table but SELECTED or SELECTEDVALUE [Start] and [End] doesn't seem to work)


Requested Start Date (RSD)
Requested End Date (RED)

// eliminate any contracts which start after the contract period requested
If the RSD is > To Date, skip record
// eliminate any contracts which end prior to the contract period requested
If the RED is < From Date, skip record

    If Full Contract
        If From Date (Year) = RSD (Year) and To Date (Year) >= RED
            AnnualCost = Total Price
        Else
            AnnualCost = $0

    If Annual or Annual Variable Payment
         //Calculated Contract Years (CCY)
        If FromDate.year = ToDate.year
            CCY = 1
        Else
           CCY = ToDate.year - FromDate.year (int)

    If CCY = 1
         AnnualCost = TotalPrice (Float)
    Else
         AnnualCost = TotalPrice/CCY (Float)

 

Contract NamePayment ScheduleTotal PriceAnnual CostFrom DateTo Date
WidgetsAnnual60,000.0060,000.007/15/20197/15/2020
GizmosAnnual80,000.0020,000.006/01/20186/01/2021
Do-DadsFull Payment200,000.000* 01/01/201601/01/2021

 

*0 will show if RSD.year is after FromDate.year else Total Price will be shown 

1 REPLY 1
Anonymous
Not applicable

The description of the calculation is ambiguous because of the very last line of your post.

Please state the algorithm unambiguously.

Best
D

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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