cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wvdmedify Frequent Visitor
Frequent Visitor

Calculate Revenue based on lookupvalues of Factors between different dates/times

I am trying to input a formula or query that can do the following:

 

Before 30/06/2019 0:00pm multiply units by price multiply by OLD factor in a lookup table.

After 30/06/2019 0:00am or from 01/07/2019 0:30am multiply units by price multiplied by a NEW factor in the lookup table.

 

currently i have the following Measure:

= GSF Net Production = CALCULATE(sumx(Gannawarra,[Net kWh]*LOOKUPVALUE(MLFs[MLF],MLFs[Solar Farm],"Gannawarra")*LOOKUPVALUE(MLFs[DLF],MLFs[Solar Farm],"Gannawarra")),filter(Gannawarra,Gannawarra[Date]<=date(2019,6,30)))/1000 + CALCULATE(sumx(Gannawarra,[Net kWh]*LOOKUPVALUE(MLFs[MLF New],MLFs[Solar Farm],"Gannawarra")*LOOKUPVALUE(MLFs[DLF New],MLFs[Solar Farm],"Gannawarra")),filter(Gannawarra,Gannawarra[Date]>=DATE(2019,7,1)))/1000
 
The above does not seem to be calculating correctly
 
Any assistance for a more streamline formula/query would be much appreciated
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Calculate Revenue based on lookupvalues of Factors between different dates/times

Hi @wvdmedify ,

 

 We can create a measure as below.

 

GSF Net Production = 
VAR k =
    FILTER (
        Gannawarra,
        'Gannawarra'[date]
            <= ( DATE ( 2019, 06, 30 ) + TIME ( 24, 0, 0 ) )
    )
VAR b =
    FILTER (
        Gannawarra,
        Gannawarra[date]
            >= ( DATE ( 2019, 06, 30 ) + TIME ( 24, 0, 0 ) )
            && 'Gannawarra'[date]
                <= ( DATE ( 2019, 07, 01 ) + TIME ( 0, 30, 0 ) )
    )
RETURN
    CALCULATE ( SUM ( Gannawarra[kWh] ), KEEPFILTERS ( k ) )
        * CALCULATE (
            MAX ( MLFs[DLF] ),
            FILTER ( MLFs, MLFs[Solar Farm] = "Gannawarra" )
        )
        + CALCULATE ( SUM ( Gannawarra[kWh] ), KEEPFILTERS ( b ) )
            * CALCULATE (
                MAX ( MLFs[DLF New] ),
                FILTER ( MLFs, MLFs[Solar Farm] = "Gannawarra" )
            )

Capture.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Community Support Team
Community Support Team

Re: Calculate Revenue based on lookupvalues of Factors between different dates/times

Hi @wvdmedify ,

 

 We can create a measure as below.

 

GSF Net Production = 
VAR k =
    FILTER (
        Gannawarra,
        'Gannawarra'[date]
            <= ( DATE ( 2019, 06, 30 ) + TIME ( 24, 0, 0 ) )
    )
VAR b =
    FILTER (
        Gannawarra,
        Gannawarra[date]
            >= ( DATE ( 2019, 06, 30 ) + TIME ( 24, 0, 0 ) )
            && 'Gannawarra'[date]
                <= ( DATE ( 2019, 07, 01 ) + TIME ( 0, 30, 0 ) )
    )
RETURN
    CALCULATE ( SUM ( Gannawarra[kWh] ), KEEPFILTERS ( k ) )
        * CALCULATE (
            MAX ( MLFs[DLF] ),
            FILTER ( MLFs, MLFs[Solar Farm] = "Gannawarra" )
        )
        + CALCULATE ( SUM ( Gannawarra[kWh] ), KEEPFILTERS ( b ) )
            * CALCULATE (
                MAX ( MLFs[DLF New] ),
                FILTER ( MLFs, MLFs[Solar Farm] = "Gannawarra" )
            )

Capture.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
wvdmedify Frequent Visitor
Frequent Visitor

Re: Calculate Revenue based on lookupvalues of Factors between different dates/times

Thanks for your response, i still seem to obtain the same value from my version to yours.  the only problem both do not agree to the amount we should invoiced.

Think it as some thing to do with the Date filter. 

Highlighted
wvdmedify Frequent Visitor
Frequent Visitor

Re: Calculate Revenue based on lookupvalues of Factors between different dates/times

Got it, just changed the dates around, solution works. Thanks!Smiley Very Happy

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 42 members 1,102 guests
Please welcome our newest community members: