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
setis
Post Partisan
Post Partisan

Calculation based on a set of rules

Dear all,

 

I'm not sure how to approach this challenge. 

I have a table with a set of rules:

 

rules.PNG

 

As you can see a case has a specific Fee_type when it meets all the conditions. 

F.Ex. A case is Easywhen the

ft_cause = A and

the case_type = Type_A and

the customer = CustomerA and

Activities <5  and

Nr calls <1.

 

I am looking for a Measure or calculated column in my cases table that gives me right price:

 

result.PNG

 

Any idea on how to approach this?

 

Thanks in advance

1 ACCEPTED SOLUTION

@setis 

 

You may try Pivot Column to shape data in Query Editor and then refer to this post.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@setis , what is the logic for desired price2 =200 for easy.  Do you need this calculation on the aggerated number or at line level

@amitchandak thanks for looking into this. 

 

I'm so sorry, there was a mistake in the table. I have just corrected it in the orogonal post. The easy price is 200.

The calculation I need is on a line level on the cases table. 

 

Thank in advance

@setis , can you provide sample data, sample rule data in table format

@amitchandak Sure!

 

Sample rule

 

ft_nameft_causeCase_typeCustomerft_operatornameft_numberFee_typeAmount
CauseME CustomerA  Difficult1000
Case Type Type_ACustomerA  Difficult1000
Customer  CustomerA  Difficult1000
Activities  CustomerALess than5Easy200
CauseME CustomerA  Easy200
Customer  CustomerA  Easy200
Case Type Type_ACustomerA  Easy200
Nr of calls  CustomerALess than1Easy200

 

Sample data

CaseIDft_causeCase_typeCustomerNr of callsNr ActivitiesDesired Result(Fee_type)Desired Result2(price)
1221METype_ACustomerA04Easy200
1222AAType_BCustomerA5 BLANKBLANK
1223METype_ACustomerA06Difficult1000

The weekend sank this post to the bottom of the forum. I'm bumping this to gain some monday morning visibility. 

I would really appreciate any help. 

@setis 

 

You may try Pivot Column to shape data in Query Editor and then refer to this post.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft thanks for your answer. You are right. That's definitiely the way to go. 

 

I am having issues doing the unpivot in power query. Could you please help me with the steps to unpivot this correctly?

 

I have upload a sample here:  https://drive.google.com/file/d/16wKtLuvvUJ8gMMV5Hk0PYFiEcCR8oAYL/view?usp=sharing

 

What I'm trying to go is from here: 

 

table1.PNG

 

To something like this:

table2.PNG

 

At the same time, do  you have any idea on how to solve the cells Activities and Calls so I have something usable to calculate with?

 

 

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.