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
Anonymous
Not applicable

Lookup value with 2 criteria from 2 tables

Hi All,

 

I have a situation where I am trying to look up the price of a VM based on its profile, and its region (from a central rate card)

 

This is the DAX code I am currently using:

 

As-Sized PAYGO = 
//Restirct to Just Windows Devices
IF (
    [Is Linux] = FALSE (),
    IF (
        'Device_Azure_Costs'[As-Size Override Active] = True (),
        //If True (Override in place)
        LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Override Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[CustomerDC]
        ),
        //else (if No Override in place)
        LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[CustomerDC]
        )
    ),
    //Do Nothing
    0
)
//Convert to Rate
*[Rate]

 

Currently, the DAX returns blank values.

 

Ideally, I would like the solution to:

 

Check if the current Profile has an override in place
     if it does, look up the overriding profile, in the rate card, taking into account the DC that is specified for the machine in question

   if there is no override, look up the provided profile in the rate card, taking into account the DC that is specified for the machine in question.

 

From that point I know I can wrap that in check statements for Linux and SQL where required.

 

How would I go about doing this?  I've included sample data below if that helps.

 

Sample Data:

Destination table: [Device_Azure_Costs]

Device NameAzure RegionIs LinuxAs-Size Override ActiveRight-Size Override ActiveAs-Sized PAYGORight-Size VM Override ProfileAs-Size VM Override ProfileRight-Size VM ProfileAs-Size VM ProfileIs SQL ServerIs SQL Server STDIs SQL Server ENTIs SQL Server NonCostCustomer DataCenter
WS2016DC03.Contoso.comwestusFalseFalseFalse[value I want to Compute][possible override profile] D1_v2D1_v2FalseFalseFalseFalseUK South
BIZTALKSQL.Contoso.comwestusFalseFalseFalse[value I want to Compute] [possible override profile]D1_v2DS15_v2TrueTrueFalseFalseWest US

[Lookup Table: AzurePricingList]

ProfileMeterRegionPayGoWin
A2UK South144.54
A1_v2UK South55.48
A1EU West72.27
A0UK South16.06
A2_v2UK South116.07
A2m_v2West US197.1
A3UK South289.08
A4_v2UK South243.09
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Based on your sample, I add 2 rows into AzurePricingList,

vxiaotang_0-1629194503277.png

then I change your dax expression as bellow

columnTest = 
//Restirct to Just Windows Devices
IF (
    [Is Linux] = FALSE (),
    IF (
        'Device_Azure_Costs'[As-Size Override Active] = True (),
        //If True (Override in place)
        LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Override Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[Customer DataCenter]
        ),
        //else (if No Override in place)
        /*LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[Customer DataCenter]
        )*/
        CALCULATE(MIN(AzurePricingList[PayGoWin]),FILTER(ALL(AzurePricingList),AzurePricingList[Profile]==Device_Azure_Costs[As-Size VM Profile]&&AzurePricingList[MeterRegion]==Device_Azure_Costs[Customer DataCenter]))
    ),
    //Do Nothing
    0
)
//Convert to Rate
//*[Rate]

result

vxiaotang_1-1629194559211.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Based on your sample, I add 2 rows into AzurePricingList,

vxiaotang_0-1629194503277.png

then I change your dax expression as bellow

columnTest = 
//Restirct to Just Windows Devices
IF (
    [Is Linux] = FALSE (),
    IF (
        'Device_Azure_Costs'[As-Size Override Active] = True (),
        //If True (Override in place)
        LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Override Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[Customer DataCenter]
        ),
        //else (if No Override in place)
        /*LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[Customer DataCenter]
        )*/
        CALCULATE(MIN(AzurePricingList[PayGoWin]),FILTER(ALL(AzurePricingList),AzurePricingList[Profile]==Device_Azure_Costs[As-Size VM Profile]&&AzurePricingList[MeterRegion]==Device_Azure_Costs[Customer DataCenter]))
    ),
    //Do Nothing
    0
)
//Convert to Rate
//*[Rate]

result

vxiaotang_1-1629194559211.png

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you very much, this solved my problem!

Anonymous
Not applicable

Hi Jos,

 

The Linux statement is not the part that is failing i dont think.

 

The clause below is failing I believe:

 

 

      LOOKUPVALUE (
            AzurePricingList[PayGoWin],
            AzurePricingList[Profile], 'Device_Azure_Costs'[As-Size VM Profile],AzurePricingList[MeterRegion],Device_Azure_Costs[CustomerDC]

 

 

What  I would expect to happen is for the Given profile [As-Sized VM Profile] Taken from Device Azure Costs, to be looked up in PricingList, while also taking into account the DC referenced in [Customer DC]

 

Larger sample of Pricing List: 

 

ProfileMeterRegionPayGoWin
A1_v2AU Central55.48
A2KR South144.54
A1UK South 286.87
A0FR South20.878
A2_v2JA West124.1
A2m_v2US Gov TX175.2
A3KR South289.08
A4_v2UK West243.09
A4m_v2AE Central370.84
A5EU North219
A6IN Central445.3
B1lsSE South8.03
B1msCH West30.222
B1sUS North Central10.512
B2msKR Central87.6
B2sEU North39.128
B4msUS East 2132.86
D1ZA North99.28
D1_v2US West91.98
D11BR South294.19
D11_v2FR South292
D12EU West408.07
D12_v2ZA North427.05
D2AU Southeast227.76
D2_v2EU North169.36
D2_v3AE North154.76
D2_v4AU Southeast158.41
D2a_v4EU West151.11
D2d_v4US Gov AZ171.55
D2ds_v4ZA West211.7
D2s_v4IN West153.3
D3US South Central379.6

 

[Larger Sample of Device_Details]

Device NameAzure RegionIs LinuxAs-Size Override ActiveRight-Size Override ActiveAs-Sized PAYGORight-Size VM Override ProfileAs-Size VM Override ProfileRight-Size VM ProfileAs-Size VM ProfileCustomer DataCenter
WS2016DC03.Contoso.comwestusFalseFalseFalse   D1_v2D1_v2UK South
BIZTALKSQL.Contoso.comwestusFalseFalseFalse   D1_v2DS15_v2West US
SPSTD.Contoso.comwestusFalseFalseFalse   D2a_v4F4s_v2UK South
WS2012R2STD23.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
WS2008STD08.Contoso.comwestusFalseFalseFalse   D1_v2D1_v2UK South
WS2016STD20.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
WS2016STD08.Contoso.comwestusFalseFalseFalse   D1_v2D1_v2UK South
WS2008R2WEB09.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
REDHAT65.Contoso.comwestusTrueFalseFalse   D1_v2F2s_v2UK South
WS2008R2ENT10.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
UBUNTU1204.Contoso.comwestusTrueFalseFalse   D1_v2D1_v2UK South
SQLENT2000.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
WS2016DC01.Contoso.comwestusFalseFalseFalse   D1_v2D1_v2UK South
WS2008R2STD07.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2UK South
WS2012R2STD12.Contoso.comwestusFalseFalseFalse   D1_v2F2s_v2

UK South

 

Right now, it doesn't appear to be taking into account the second criteria (the region)

I'm still not sure what you mean. For the new dataset you've provided, I would still expect As-Sized PAYGO to return all blanks, since there are no rows which match the criteria you specify within the LOOKUPVALUE construction.

In fact, your new version of the Device_Azure_Costs table comprises only 3 distinct combinations of Right-Size VM Profile and CustomerDC, i.e.:

 

D1_v2 with UK South

D1_v2 with West US

D2a_v4 with UK South

 

yet none of these 3 combinations can be found in the AzurePricingList table, so naturally LOOKUPVALUE returns BLANK.

Regards

Jos_Woolley
Solution Sage
Solution Sage

Hi,

Could you provide more realistic datasets? For the samples you've provided, the two rows in the Device_Azure_Costs table have an Is Linux entry of FALSE, which means that your DAX statement is evaluating the second clause in both cases. However, in both of those cases there is no corresponding entry in the AzurePricingList table which matches the conditions specified, so naturallly they both return BLANK().

Regards

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.