cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Helper II

## Newbie - Basic Cost/Sales question

Hi

I have worked on structuring my data, to work in my power bi model.

But working with it now, im not sure acuatly how to do it.

The essense if I have 2 fact tables - Cost and Sales.

table: Cost

 CreditorNumber Order Type ParcelNumber Amount 1 100 Freight 12345 8 1 100 Surcharge 111111 1 2 105 Freight 321654 9 2 105 Surcharge 222222 1 2 110 Freight 789456 9 2 110 Surcharge 8887979 1

Table:Sales

 CreditorNumber Type ParcelNumber AmountSales Order 1 Freight 12345 10 100 1 Surcharge 111111 1 100 2 Freight 321654 15 105 2 Surcharge 222222 2 105

What im trying to do, it comparing my amount of cost to my amount of sales.

But freight and surcharge is sold out of diffenret flows.

So I want first to check if there is a match between Cost->Sales on order and type
if not, then if there is a link between Cost-> Sales on Parcel number and type

So I end someling like this:

 CreditorNumber Order Type ParcelNumber CostAmount SalesAmount 1 100 Freight 12345 8 10 1 100 Surcharge 111111 1 1 2 105 Freight 321654 9 15 2 105 Surcharge 222222 1 2 2 110 Freight 789456 9 0 2 110 Surcharge 8887979 1 0

or, my assumption is, this is the way to do it?

Any help would be appriciated. I can provide what ever is needed.

1 ACCEPTED SOLUTION
Super User

@DennisSchlein , Create a new column in the sales table

new cost =

Var _max = maxx(filter(cost, cost[Order] = sales[Order] && cost[TYpe] = sales[Type]), cost[Amount])

var _max = maxx(filter(cost, cost[parcelNumber] = sales[parcelNumber] && cost[TYpe] = sales[Type]), cost[Amount])

return

coalesce(_max, _max1)

or new column in cost

new cost =

Var _max = maxx(filter(sales, cost[Order] = sales[Order] && cost[TYpe] = sales[Type]), sales[sales Amount])

var _max = maxx(filter(sales, cost[parcelNumber] = sales[parcelNumber] && cost[TYpe] = sales[Type]), sales[sales Amount])

return

coalesce(_max, _max1)

2 REPLIES 2
Helper II

Hi @amitchandak , ill take a look and get back to you 🙂

Super User

@DennisSchlein , Create a new column in the sales table

new cost =

Var _max = maxx(filter(cost, cost[Order] = sales[Order] && cost[TYpe] = sales[Type]), cost[Amount])

var _max = maxx(filter(cost, cost[parcelNumber] = sales[parcelNumber] && cost[TYpe] = sales[Type]), cost[Amount])

return

coalesce(_max, _max1)

or new column in cost

new cost =

Var _max = maxx(filter(sales, cost[Order] = sales[Order] && cost[TYpe] = sales[Type]), sales[sales Amount])

var _max = maxx(filter(sales, cost[parcelNumber] = sales[parcelNumber] && cost[TYpe] = sales[Type]), sales[sales Amount])

return

coalesce(_max, _max1)

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.