cancel
Showing results for
Did you mean:
Highlighted
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

## 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" )
)
```

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

## 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" )
)
```

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

Frequent Visitor

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

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

Announcements

Power BI Super User, Greg Deckler, explains

#### Power Platform Summit North America

Register by September 5 to save \$200

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 6 members 1,299 guests
Recent signins: