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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
ThomasSan
Helper IV
Helper IV

Have calculate distinguish column values

Hi everyone

 

In one of my dashboards, I am attempting to create a graph that looks as follows:

ThomasSan_1-1671645387208.png

The idea is to compare the performance over the course of a year of multiple years.

 

To do that, I have set up the following visual:

ThomasSan_0-1671645332558.png

My current measure looks as follows:

Test Measure = 
var curr =
CALCULATE(
    sum('Table'[SalesTotalEUR]),
    KEEPFILTERS(
        'Table'[Date]
    )
)

var refer =
CALCULATE(
    sum('Table'[SalesTotalEUR]),
    FILTER(
        ALL('Date'[Date]),
        Month('Date'[Date])=1
    )
)

var div=
DIVIDE(
    curr,
    refer,
    ""
)

return div 

 

My problem is that I am unable to keep my measure restricted to the year column. Therefore, all my January values (be they from 2021 or from 2022) are being used in my calculations. Can anyone therefore please tell me how to set up my measure so that it distinguished between the column values?

 

 

1 ACCEPTED SOLUTION
ThomasSan
Helper IV
Helper IV

So, after some more researching and plenty of trials and errors, I was finally able to find the correct dax command for the problem It is as follows:

 

 

 

Test Measure = 

var yearselected=
SELECTEDVALUE('Date'[Date].[Year])

var curr =
sumx('Table', 'Table'[SalesTotalEUR])

var refer =
CALCULATE(
    sum('Table'[SalesTotalEUR]),
    FILTER(
        ALL('Date'[Date]),
        Month('Date'[Date])=1 && year('Date'[Date])=yearselected
    )
)

var div=
DIVIDE(
    curr,
    refer,
    ""
)

return div

 

 

 

As you can see, as SELECTEDVALUES that has to be brought in as a variable is needed.

 

The resulting visual looks as desired:

ThomasSan_0-1671709140730.png

 

View solution in original post

6 REPLIES 6
ThomasSan
Helper IV
Helper IV

So, after some more researching and plenty of trials and errors, I was finally able to find the correct dax command for the problem It is as follows:

 

 

 

Test Measure = 

var yearselected=
SELECTEDVALUE('Date'[Date].[Year])

var curr =
sumx('Table', 'Table'[SalesTotalEUR])

var refer =
CALCULATE(
    sum('Table'[SalesTotalEUR]),
    FILTER(
        ALL('Date'[Date]),
        Month('Date'[Date])=1 && year('Date'[Date])=yearselected
    )
)

var div=
DIVIDE(
    curr,
    refer,
    ""
)

return div

 

 

 

As you can see, as SELECTEDVALUES that has to be brought in as a variable is needed.

 

The resulting visual looks as desired:

ThomasSan_0-1671709140730.png

 

AlexisOlson
Super User
Super User

You shouldn't need a new measure to generate a chart like this. Put Month on the x-axis and Year in the Legend box like this:

 

AlexisOlson_0-1671647863359.png

Hi @AlexisOlson ,

 

thanks for your reply. How would you set up your example to have your Sales Amount values normalized to 100 in January of every year? My goal is to show the relative change of my sales figures over the course of a year (e.g. sales grew by 10% in February 2021 (i.e. line goes to 110) while sales in February 2022 decreased by 6% (i.e. line goes to 94)). You can see what I mean in the graph above.

 

How would you approach this?

Ah, I missed that detail. Try this:

Normalized Sales = 
DIVIDE (
    [Sales Amount],
    CALCULATE (
        [Sales Amount],
        REMOVEFILTERS ( 'Date'[Month Number] ),
        'Date'[Month] = "January"
    )
)

The removes the month name and month number filter context without removing the year filter context.

Hi @AlexisOlson ,

 

unfortunately, this only fills out the January cells in my table

ThomasSan_0-1671695158534.png

I have slightly modified your command in order to fit my tables

Test 3 = 
DIVIDE (
    sum('Table'[SalesTotalEUR]),
    CALCULATE (
        sum('Table'[SalesTotalEUR]),
        REMOVEFILTERS ( 'Date'[Month Number] ),
        'Date'[Date].[Month] = "January"
    ),
    ""
)

 

Any idea how to have the CALCULATE section of your solution expanded to all cells?

I'm guessing your model doesn't have exactly the same columns with the same names as the file I was testing with. Do you have columns for month name, month number, and year in your date table? If so, what are they? If not, then my solution clearly won't work since it's referencing non-existing things.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.