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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
KMadsen
Regular Visitor

Apply time period to IF measure

Hi All,

I have an exisitng measure that works well - it is based on a number of "IF" statement and in the end calculates the accuracy of a forecast. 

Forecast accuracy Consensus = if(sum('Region consolidated data'[Total demand])=0 && sum('Region consolidated data'[ABS deviation consensus])<>0,0,if(1-DIVIDE(

    SUM('Region consolidated data'[ABS deviation consensus]),
    SUM('Region consolidated data'[Total demand])
)<0,0,1-divide(sum('Region consolidated data'[ABS deviation consensus]),sum('Region consolidated data'[Total demand]))))

 

I can filter the data to only show the last 3 months, 6 months etc. through the date slicer. 

 

However, I would also like to have a "static" measure for the last 3 month, 6 months and 12 months to be able to show these side by side in a table.

 

Can anyone advise on how I can create "new" measures based on above but limited to the mentioned time periods?

 

Thanks!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could create a calculation group with calculation items for each period you want to show, e.g.

3 months =
VAR StartDate =
    EOMONTH ( TODAY (), -4 ) + 1
RETURN
    CALCULATE (
        SELECTEDMEASURE (),
        'Date'[Date] >= StartDate
            && 'Date'[Date] <= TODAY ()
    )

View solution in original post

2 REPLIES 2
daXtreme
Solution Sage
Solution Sage

You should ditch your IF's in favour of SWITCH. Second, creating a 'static' measure is simple - use the right filters on your existing measures.

johnt75
Super User
Super User

You could create a calculation group with calculation items for each period you want to show, e.g.

3 months =
VAR StartDate =
    EOMONTH ( TODAY (), -4 ) + 1
RETURN
    CALCULATE (
        SELECTEDMEASURE (),
        'Date'[Date] >= StartDate
            && 'Date'[Date] <= TODAY ()
    )

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors