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
ElieK
Helper I
Helper I

Trying to use measures to calculate rates based on date

Hello,

 

The organisation I work at recently changed the rates based on the team doing the work, I've been trying to figure out how to use a measure to calculate the revenue based on the new rate.

The old rates before 01-Aug-2020

Team A150
Team B75
Team C80

 

The new Rates after 01-Aug-2020

Team A170
Team B85
Team C100

 

The measure I am using is:

Team A Revenue = CALCULATE(TeamTracker[Volume]*150,TeamTracker[Team Name]="Team A")
I tried enclossing the Calculate function in an IF Statement but could not figure out how to look at the Date column in the 'TeamTracker' table.
 
I tried creating a new Measure for the Team A Rate and using
Team A Rate = IF (Today() < Date(2020,08,01) , 150, 170)
But that just ends up taking the new value, and I cant figure out how to replace the Today() with a date value from either my TeamTracker table or Rolling Calendar table
 
Thanks
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @ElieK 

I build three table to have a test.

Old Rate Table:

1.png

New Rate Table:

2.png

TeamTracker Table:

3.png

Then I build a measure to achieve your goal.

Revenue = 
VAR _VOLUME =
    SUM ( TeamTracker[Volume] )
VAR _OLDRATE =
    CALCULATE (
        SUM ( 'Old Rates'[Rate] ),
        FILTER ( 'Old Rates', 'Old Rates'[Team] = MAX ( TeamTracker[Team] ) )
    )
VAR _NEWRATE =
    CALCULATE (
        SUM ( 'New Rates'[Rate] ),
        FILTER ( 'New Rates', 'New Rates'[Team] = MAX ( TeamTracker[Team] ) )
    )
RETURN
    IF (
        MAX ( TeamTracker[Date] ) < DATE ( 2020, 08, 01 ),
        _VOLUME * _OLDRATE,
        _VOLUME * _NEWRATE
    )

Result:

4.png

You can download the pbix file from this link: Trying to use measures to calculate rates based on date

 

Best Regards,

Rico Zhou

 

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

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @ElieK 

I build three table to have a test.

Old Rate Table:

1.png

New Rate Table:

2.png

TeamTracker Table:

3.png

Then I build a measure to achieve your goal.

Revenue = 
VAR _VOLUME =
    SUM ( TeamTracker[Volume] )
VAR _OLDRATE =
    CALCULATE (
        SUM ( 'Old Rates'[Rate] ),
        FILTER ( 'Old Rates', 'Old Rates'[Team] = MAX ( TeamTracker[Team] ) )
    )
VAR _NEWRATE =
    CALCULATE (
        SUM ( 'New Rates'[Rate] ),
        FILTER ( 'New Rates', 'New Rates'[Team] = MAX ( TeamTracker[Team] ) )
    )
RETURN
    IF (
        MAX ( TeamTracker[Date] ) < DATE ( 2020, 08, 01 ),
        _VOLUME * _OLDRATE,
        _VOLUME * _NEWRATE
    )

Result:

4.png

You can download the pbix file from this link: Trying to use measures to calculate rates based on date

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Thanks @v-rzhou-msft  this helped a lot

amitchandak
Super User
Super User

@ElieK , share the data with that you want to use the rate.

 

New column = Switch( True(),

[Date] <=date(2018,01,01) && [Team] ="A" , [Volume]*150,

[Date] > date(2018,01,01) && [Team] ="A" , [Volume]*170,

/// Add other codition

 

Thanks! Is using a Calculated column the best way of doing this?

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.