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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
jts44246
New Member

Adapting Excel formula to Calculated Measure for Percent of Fiscal Year Elapsed

I have an Excel formula that calculates the percent of fiscal year that elapsed for the current date, and I want to use it in a calculated measure to add it as a dimension field on a PivotTable Cube. However, Copilot generated an error when I tried to adapt it to a calculated measure. Here's the Excel formula:

Copy
 
=(1-((DATE(IF(MONTH(TODAY()-1)>7,YEAR(TODAY()-1)+1,YEAR(TODAY()-1)),6,30)-TODAY()-1)/365))

And here's what Copilot generated:

Copy
 
WITH MEMBER [Measures].[MyCalculatedMeasure] AS
    '1 - (
      (
        DateSerial(
          IIf(Month(NOW() - 1) > 7, Year(NOW() - 1) + 1, Year(NOW() - 1)),
          6,
          30
        ) - NOW() - 1
      ) / 365'
SELECT
  [Measures].[MyCalculatedMeasure] ON 0
FROM [munprod_General Ledger Cubes]

Does anyone know how to fix this error and adapt the Excel formula to a calculated measure?

3 REPLIES 3
jts44246
New Member

Thanks,

 

Where are you entering this script? I am adding it to the Edit Calculated Measure window (below) but I receive the follow error (further below).  Should this go somewhere else?

jts44246_1-1709223717099.png

 

jts44246_0-1709223699359.png

 

Anonymous
Not applicable

Hi @jts44246 ,

What I using is Power BI Desktop, and create a measure in it. You can find the details in the attachment.

Get started with Power BI Desktop - Power BI | Microsoft Learn

vyiruanmsft_0-1709277401504.png

vyiruanmsft_1-1709277948966.png

 

Where do you want to apply the calculation logic?  Excel or other software? Could you please provide some sample data and the expected result with backend scenario?

Best Regards

Anonymous
Not applicable

Hi @jts44246 ,

You can create a measure as below with the same formula in Excel to get the same result...

Measure = 
(
    1
        - (
            (
                DATE ( IF (
                    MONTH ( TODAY () - 1 ) > 7,
                    YEAR ( TODAY () - 1 ) + 1,
                    YEAR ( TODAY () - 1 )
                ), 6, 30 )
                    - TODAY () - 1
            ) / 365
        )
)

vyiruanmsft_0-1709193493655.png

Best Regards

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.