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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Danminar
Frequent Visitor

Help with DAX Value from one table matching up with another with conditions

Hey All,
Hope anyone can help, what I'm trying to accomplish is a bit of logic to add columns to a table based off another table.  In a measure, I think I can accomplish this more easily but this data (which can be larger) will be digested in Excel.  Anyways, the logic needs to be a such:
One table is a financial table, this table has an account # (cost element) and this along with a variant will decide the regulatory account which is based off another table.
So the 1st table is the financial table:

Order numberReg IndCost element Jan VariantReg Acct
10014620600200140       29,152.00OPSEF4320
10524600886899999        (2,624.00)F4040F4040
10574800622100800        (3,954.00)OEEDF5890
10585500622100801         8,492.00OEEDF5890
10624560649900200             271.00OEEDF4560
10634560649900200         1,574.00OEEDF4560

The Reg Acct column is the one I need, it's based off another table's dimensions.  (Reg Table)

VariantFrom Cost ElementTo Cost ElementRegulatory account
OPSE621000135621000150F4320
ALL600300240600300240F5550
ALL886809999886809999F4040
OEED622100800622100849F5890

So the gist is, go to the financial table and 1 of 3 things occurs: (bold in Financial Table is desired result)
#1 Looking up cost element from financial table, compare to Reg Table and check to see if it falls between "from" or "to" cost elements, if Variant from Reg Table says "All", then simply return Regulatory Account from Reg Table
#2 Look up cost element from financial table, find range from Reg Table and if also a match of Variant between the two tables, return the combination of the two from the Regulatory Account from the Reg Table.
#3 If cost element from financial table does not fall into the range of cost elements from Reg table OR does fall into the range but no match of BOTH cost element range AND Variant then return Reg Account from Financial Table (+ "F" preceding

5 REPLIES 5
Danminar
Frequent Visitor

Ross, I gave it a shot and the formulas seem to make sense but I'm not getting the desired results, basically getting nothing. I tried to attach the sample file and unsure if I did a good job of communicating what I required.
Thanks!

Sorry Danminar, i'm not in a position to be downloading and reviewing other people files.

No worries, totally understand you at least gave me a direction...

RossEdwards
Solution Sage
Solution Sage

I think i understand what you are asking for but if not hopefully the below will give you a starting point to work from.  It is assumed the below is a DAX calculated column called "Reg Acct" for your Financial Table

Reg Acct = VAR finCostElement = [Cost element]
VAR finVariant = [Variant]
VAR regVariant = CALCULATE(
    SELECTEDVALUE('RegTable'[Varient]),
    FILTER(
        ALL('RegTable'),
        'RegTable'[From Cost Element] <= finCostElement &&
        'RegTable'[ToCost Element] >= finCostElement
    )
var regRegAccount = CALCULATE(
        SELECTEDVALUE('RegTable'[Regulatory account]),
        FILTER(
            ALL('RegTable'),
            'RegTable'[From Cost Element] <= finCostElement &&
            'RegTable'[ToCost Element] >= finCostElement
        )
    )
VAR output = IF(
    regVariant = "ALL",
    regRegAccount,  //#1 result
    IF(
        finVariant = regVariant,
        regRegAccount,  #2 result
        regRegAccount & "F"  // #3 result
    )
)
RETURN
output

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.