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.

View solution in original post

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.

View solution in original post

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
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and 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.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 6 members 3,003 guests
Please welcome our newest community members: