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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Shahzz77
Frequent Visitor

how to make first and last row value zero with parameter

I am trying to make my first and last row value as zero . I used switch function to do it .

I have a parameter tenure with values 1 2 3 4 5 and forecasted parameter 2021,2022,2023,2024.......

If my tenure is 4 and forecasted year is 2022 then my 2022-4=2018 i.e value of forecasted year and value of year < 2018 should get zero. 
so that i can take the sum of value from 2018+2019+2020+2021 from the table1.

newmeasure = selectedvalue[timeperiod]-tenure
new column =
var forecastedyear= year(today())+1
return
switch(true(),
year(sample[timeperiod].year = forecastedyear,0,
year(sample[timeperiod].year < newmeasure,0
return
table1
Yearvaluenew column
201711
201811
201911
202011
202111
202210

 

Problem in the dax is when i am passing the newmeasure in my new column dax it is making only forecasted value zero , but value less than year 2018 is still the same . 

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Shahzz77 It's generally not advisable to use a measure as part of a calculated column. What happens in you column if you just simply return newmeasure?



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

if i am not using it as a colum then how do i select my slect my years to get considered ..what dax i have to write..  time period values how to slect 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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