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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
rokas147
Frequent Visitor

If statement with year

Hi all,

 

this is the problem I am facing. I have 3 years, 2018, 2019 and 2020. 

The formula I am using:

 

Case study calculated = IF('2018-2019-2020_data'[Year]="2020",(SUM('2018-2019-2020_data'[Case studies])/0.67*'Case Study discount'[Case Study discount Value]/100), SUM('2018-2019-2020_data'[Case studies]) )
P.s. when writing this formula I get an error stating: a single value for column "Year" cannot be determined. 
 
Case study discount value = is a value in the slicer.
 
My goal is, to have case study calculated WITH the slicer value for the year 2020, in other years 2018 and 2019, I just want the value of case studies. 
 
Currently, as I cannot implement this function the slicer for case studies affects all year, but it should only affect year 2020.
 
My year column only contains values such as 2018, 2019 or 2020.
 
Any help would be highly appreciated.
 
Cheers
7 REPLIES 7
rokas147
Frequent Visitor

Lol, i just had to create a column instead of a measure, my faultsies boys and girls, apologize

 

v-rzhou-msft
Community Support
Community Support

Hi @rokas147 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file from your Onedrive for Business.

 

Best Regards,

Rico Zhou

v-rzhou-msft
Community Support
Community Support

Hi @rokas147 

Do you want to build a calculated column or a measure?

If you want to build a measure, use max function to get the Year value in '2018-2019-2020_data'.

If you want to build a calculated column, you use values from different tables. In which table do you want to build this calculated table, 'Case Study discount' or '2018-2019-2020_data'. If you want to build a calculated column in 'Case Study discount', you can't use Case studies and Year in '2018-2019-2020_data' directly, try to use related function to get the value.

You may refer to this blog for more details: Dax Error

If this reply still couldn't help you solve your problem, please share a sample with me by your Onedrive for Business.

And show a the result you want by screenshot. This will make it easier for me to understand your requirement.

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Anonymous
Not applicable

Show an example

Anonymous
Not applicable

 Why not create a calculated column in your table ?

CaseStudiesCalculated = 

IF('2018-2019-2020_data'[Year]="2020",'2018-2019-2020_data'[Case studies])/0.67*'Case Study discount'[Case Study discount Value]/100),SUM('2018-2019-2020_data'[Case studies])

 

Then show the SUM of column in your visual

Thats the problem, when try using IF statement, it does not detect my "Year Column", therefore, it doesnt work

The problem is I cannot select '2018-2019-2020_data'[Year], thus the question is maybe I should be accessing this data somewhat different, I have tried uploading it as a string and as a numeric value. It didn't work both times 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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