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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculate difference between two values using strings

Hi there,

 

I am trying to calculate the difference between two scores, one is before (Pre) the learning, another is after (Post).

 

We have a field called QuestionCategory which contains the product-questiontype_detail.  An example would be: 'Maths-Confidence_Pre' this example shows the confidence (a whole number) a learner had in maths before the learning.

 

A similar row will be 'Maths-Confidence_Post' to show the confidence of the learner after completion.

 

I would like to calculate the difference between the two confidence scores based on the product.

 

Learner IDQuestion CategoryQuestionScore (1-7)Desired Result: Confidence ChangeNotes
1Maths-Confidence_PreBefore you start learning, how confident are you in the subject?32The confidence before the course is 3 and after 5, giving a difference of 2
1Maths-Confidence_PostNow you have finished, how confident are you in the subject?52The confidence before the course is 3 and after 5, giving a difference of 2
2Maths-Confidence_PreBefore you start learning, how confident are you in the subject?24The confidence before the course is 2 and after 6, giving a difference of 4
2Maths-Confidence_PostNow you have finished, how confident are you in the subject?64The confidence before the course is 2 and after 6, giving a difference of 4
3Maths-Confidence_PreBefore you start learning, how confident are you in the subject?2 Only have a confidence result for before learning.  May not have finished yet or didn't complete questions.
5English-Confidence_PreBefore you start learning, how confident are you in the subject?4-1The confidence before the course is 4 and after 3, giving a difference of -1 (representing a decrease in confidence)
5English-Confidence_PostNow you have finished, how confident are you in the subject?3-1The confidence before the course is 4 and after 3, giving a difference of -1 (representing a decrease in confidence)
7English-Confidence_PostNow you have finished, how confident are you in the subject?6 Only have a confidence result for after learning.  May not have answered initial questions.

 

This is an example set of data for the problem.  Ideally we would like to have a column like 'Desired Result: Confidence Change'

 

I've tried many things, but I'm pretty new to Power BI 🙂 any help is greatly appreciated!

 

I couldn't workout how to upload a pbix

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous,

Can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Anonymous , The best way to have duplicate this column and split that into 2 column and use.

 

Or have measures like

 

Pre Marks= Calculate(Sum(Table[Marks]), filter(Table, search("Pre", Table[Exam],,0) >0) )

 

Psot Marks= Calculate(Sum(Table[Marks]), filter(Table, search("Post", Table[Exam],,0) >0) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak thanks for your quick response!
I've tried creating the columns but I think I'm getting the syntax mixed up with Tableau (we recently switched)

Pre = CONTAINSSTRING(Table[QuestionCategory], "Pre") then Table[Score]

But this is giving me true/false

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors