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
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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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