Forum Discussion
Joining multiple formulas into one
Hi,
I have about 4 formulas that I have created seperately that I would love to join together in one formula. The screenshot below, the column test validation 2 is the end result that I want to show up "only". However, I want a single formula to give me all the other counts that I need to get to the final result. I am attaching a link to the PBIX file and a screenshot of data. Please note, I want to only use columns QUALITY and RECOMMENDED in my calculations and not all the other measures that I created to get to the TEST VALIDATION 2 result.
https://drive.google.com/open?id=1unaCLVMIXE4JB17Q39eXu6SR4jIPMlz5
12 Replies
- VvelardeCommunity Champion
Hi, you can use variables inside the measure.
My TestValidation 2% = VAR Quality_10_Score_Count = CALCULATE ( COUNT ( Sheet1[Quality] ); Sheet1[Quality] = 10 ) VAR Quality_Score_10_and_Recommended_Score_9_or_10 = CALCULATE ( COUNT ( Sheet1[Quality] ); Sheet1[Quality] = 10; Sheet1[Recommended] = 10 || Sheet1[Recommended] = 9 ) VAR Quality_Score_10_and_Recommended_Score_9_10_V2 = CALCULATE ( COUNT ( Sheet1[Quality] ); Sheet1[Quality] = 10; Sheet1[Recommended] <= 6 ) VAR Test_Validation_2_Recommended_Score = Quality_Score_10_and_Recommended_Score_9_or_10 - Quality_Score_10_and_Recommended_Score_9_10_V2 RETURN Test_Validation_2_Recommended_Score / Quality_10_Score_CountRegards
Victor
Lima - Peru
- nmck86Post Patron
The only thing is I only want to use columns Recommended and Quality inside the calculation. Can you show me how I would do that not using all those pre-created measures. I only want to use the 2 values that are actually inside my dataset. The image below shows the only 2 true data points in the file. Is there a way to get it combined using only those fields?
- VvelardeCommunity Champion
- stretcharmMemorable Member
Use Vars
Test Validation 2 % Calc = VAR Q10 = CALCULATE ( COUNT ( Sheet1[Quality] ), Sheet1[Quality] = 10 ) VAR Q9_10 = CALCULATE ( COUNT ( Sheet1[Quality] ), Sheet1[Quality] = 10, Sheet1[Recommended] = 10 || Sheet1[Recommended] = 9 ) VAR Q10_R9 = CALCULATE ( COUNT ( Sheet1[Quality] ), Sheet1[Quality] = 10, Sheet1[Recommended] <= 6 ) VAR TestVal2 = Q9_10 - Q10_R9 RETURN TestVal2 / Q10- stretcharmMemorable Member
:smileyhappy:
I was too slow Vvelarde got there just before me.
Notice we both use https://www.daxformatter.com/ to make the code more readable.