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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wvdmedify
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
v-frfei-msft
Community Support
Community Support

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 others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

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 others find it more quickly.

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. 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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
Top Kudoed Authors