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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Kavya_Mahesh
Regular Visitor

Power BI DAX syntax to calculate value from two different column for different time frame

Hi,

I have three type of value Low, Average and High calculated in three different column for a 1000+ entries in excel for timeframe starting from 1970 to 2030.

What would be the DAX syntax to create new column and get high value for year 1970 to 2026 and Avergae value for year 2027 to 2030.

Appreciate help on this.

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @Kavya_Mahesh ,

 

Try this

NewColumn =
IF(
'YourTable'[Year] >= 1970 && 'YourTable'[Year] <= 2026,
'YourTable'[High],
IF(
'YourTable'[Year] >= 2027 && 'YourTable'[Year] <= 2030,
'YourTable'[Average],
BLANK()
)
)

View solution in original post

5 REPLIES 5
govind_021
Responsive Resident
Responsive Resident

Hey Try this approach , 
New Value =
IF(
YEAR(YourTable[DateColumn]) <= 2026,
YourTable[High],
IF(YEAR(YourTable[DateColumn]) >= 2027 && YEAR(YourTable[DateColumn]) <= 2030,
YourTable[Average],
BLANK() -- This will return blank for other years outside 1970-2030
)
)

Anonymous
Not applicable

Hi @Kavya_Mahesh

Thanks for the reply from FarhanJeelani.

 

Could you please share a bit more about your excel table like sample data?

 

Do you want to create a calculated column assigning different value based on year addressed?

 

If so, I have made a test for your reference.

 

Here is my sample data:

vqiaqimsftv_0-1736834165605.png

 

You could directly create a calculated column and write the DAX as below:

 

NewColumnTest = 
VAR _YearValue = YEAR('Table'[Date])  -- Extract the year from DateValue
RETURN
    IF(
        _YearValue <= 2026, 
        'Table'[High], 
        IF(
            _YearValue >= 2027 && _YearValue <= 2030, 
            'Table'[Average], 
            BLANK()
        )
    )

 

 

Here is the testing result:

vqiaqimsftv_1-1736834219733.png

I would be grateful if you could provide me with the pbix file or sample data.

 

The pbix file is attached.

 

If you have any other question please feel free to contact me.

 

Best Regards,
Qi
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi,

Thank you so much for the solution.

 

The sample you have created is exactly what I was looking for, except I directly have year column, so I guess I can skip the extract function.

 

Regards

Mahesh 

FarhanJeelani
Super User
Super User

Hi @Kavya_Mahesh ,

 

Try this

NewColumn =
IF(
'YourTable'[Year] >= 1970 && 'YourTable'[Year] <= 2026,
'YourTable'[High],
IF(
'YourTable'[Year] >= 2027 && 'YourTable'[Year] <= 2030,
'YourTable'[Average],
BLANK()
)
)

Hi,

Thank you so much.

This worked perfectly.

Regards

Mahesh 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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