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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
kemaley
Frequent Visitor

How can I convert a value calculated measure to a static value.

I know that this question has been asked many times, but I have not been able to reach a conclusion by analyzing them.

As can be seen in the code below, I want to add the total sales amount of the previous year to the first month of the selected year and reach the cumulative sales amounts on a month basis in the selected year.

Sample data is as follows. For convenience in the sample data, I made the sales figures for both years the same.

Monthly Sales 2017 : 10,20,30,40,50,60,70,80,90,100,110,120
Monthly Sales 2018 : 10,20,30,40,50,60,70,80,90,100,110,120

The chart I want to reach with the criteria I want to reach will only show the sales for 2018, but the sales amount (120) for 2017 will be added to these sales. So the result data will be as follows.

Result Data : 130,140,150,160,170,180,190,200,210,220,230,240

I made the code as follows.

Cumulative Sales = 
VAR PreviousYearAmount =
 
SUMX (
    FILTER (
        'Sales',
        'Sales'[Year]<'Parameter Year'[Parameter Year Value]
    ),
'Sales'[Amount]
)
 
VAR SelectedYearByAmount = 
 
CALCULATE(
    SUMX('Sales',
        'Sales'[Amount],
    )
    ,
 
   FILTER(
ALLSELECTED('Months'),
'Months'[MonthsNum]<=MAX('Months'[MonthsNum])
),
FILTER(
ALLSELECTED('Years'),
'Years'[Year]='Parameter Years'[Parameter Year Value]
)
      
)
 
RETURN
 
PreviousYearAmount + SelectedYearAmount



I want the PreviousYearAmount in the code to remain constant, but it also enters the filter. How can I make it static.

Thanks in advance

 

1 ACCEPTED SOLUTION
kemaley
Frequent Visitor

I have found solution

Cumulative Sales = 
VAR PreviousYearAmount =
CALCULATE(
SUMX (
    FILTER (
        'Sales',
        'Sales'[Year]<'Parameter Year'[Parameter Year Value]
    ),
'Sales'[Amount]
),
ALL(Months)
)

Thanks

View solution in original post

1 REPLY 1
kemaley
Frequent Visitor

I have found solution

Cumulative Sales = 
VAR PreviousYearAmount =
CALCULATE(
SUMX (
    FILTER (
        'Sales',
        'Sales'[Year]<'Parameter Year'[Parameter Year Value]
    ),
'Sales'[Amount]
),
ALL(Months)
)

Thanks

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.