Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreShape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.
Hi,
I have the fact table "fct_bookings" that looks like this:
In my dimension table "dim_distributor" I would like to create two calculated columns:
Net USD - which will result in the sum of all Net USD values from fact table for currency that has the highest share (based on Net USD value) for that particular customer
Currency - currency code with the highest share (based on Net USD value)
Result would look like this:
Can you help me with DAX for columns "Net USD" and "Currency"?
1 Net USD =
VAR maxusd = CALCULATE(MAX('fct_bookings'[Net USD]),ALLEXCEPT('fct_bookings'[BT Customer No]))
RETURN
maxusd
2 ) Currency =
VAR maxcurrency = CALCULATE(MAX('fct_bookings'[Trx Currency Code]),[Net USD]))
RETURN
maxcurrency
@FreemanZ , yes - one to many relationship from dim_distributor to fct_bookings by the field BT Customer No
hi @PshemekFLK
try to create two calculated columns like:
Currency =
MAXX(
TOPN(
1,
RELATEDTABLE(fct_bookings),
CALCULATE(SUM(fct_bookings[NetUSD]))
),
fct_bookings[Currency]
)
NetUsD =
SUMX(
TOPN(
1,
RELATEDTABLE(fct_bookings),
CALCULATE(SUM(fct_bookings[NetUSD]))
),
fct_bookings[NetUSD]
)
it worked like:
@FreemanZ This works great! Many thanks! One additional question: what if I add a grouping of customers to my dimensions table like this:
What would the DAX look like for "Group Currency"?
Hi @FreemanZ ,
I mean if one customer ordered 399 in GBP and 300 in EUR then result should show 399 in GBP as it is higher than EUR, I just edited the second table with the correct desired result. Apologies for confusion.
User | Count |
---|---|
24 | |
21 | |
19 | |
13 | |
12 |
User | Count |
---|---|
40 | |
28 | |
28 | |
22 | |
20 |