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
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
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.