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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jdciaravino
Regular Visitor

Conditional row calculation using a parameter

Hi All,

 

Did some researching on this but couldn't quite get the right answer. So figured I'd post this here.

 

Essentially I have year and sales data. (see below)Year and Sales.PNG

 I want to create a new column, which for the years 2017-2035 just duplicates the sales data, but for the year 2016 I want to take a percentage of the 2016 sales data based on a parameter the user can control. I will call this the inclusion portion of 2016. The parameter is number of days in 2016 to include "0-365" then divided by 365 to get a percentage.

 

I tried this with a table calculation however I read that parameters do not work within table calculations and kept getting no result for 2016. I used the below DAX formula and syntax. but this gave me no result.

 

 

Dax - Row Parameter Formula.PNG

 

See below for my result

New Column Result.PNG

Any ideas how I would perform this calculation with a measure?

 

Please let me know if there is other data necessary to show to answer this question.

 

Regards

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

You should just have to wrap your [Year] portion in an aggregation like MAX to make that a measure as well as wrapping any other reference to a column in some type of aggregation like SUM or MAX depending on what you are trying to do.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-yuezhe-msft
Employee
Employee

@jdciaravino,

It seems that you are creating a calculated column rather than measure. Right click your table and select "New Measure", then apply the following DAX.


Measure = IF(MAX('SA SWS'[Year])=2016,MAX('SA SWS'[Sales])*'SA SWS'[Selectd Inclusion Value],MAX('SA SWS'[Sales]))



Regards,
Lydia

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

View solution in original post

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@jdciaravino,

It seems that you are creating a calculated column rather than measure. Right click your table and select "New Measure", then apply the following DAX.


Measure = IF(MAX('SA SWS'[Year])=2016,MAX('SA SWS'[Sales])*'SA SWS'[Selectd Inclusion Value],MAX('SA SWS'[Sales]))



Regards,
Lydia

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

You should just have to wrap your [Year] portion in an aggregation like MAX to make that a measure as well as wrapping any other reference to a column in some type of aggregation like SUM or MAX depending on what you are trying to do.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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