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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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

 

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yiruan-msft
Community Support
Community Support

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

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.