Forum Discussion

GracieLeeMonroe's avatar
GracieLeeMonroe
Frequent Visitor
4 years ago

Lookup does not work

All

I am trying to get a date by certain criterias (serial no. and Product type) since I need to calculate the difference between those dates in month in order to calculate the correct quantity of periods to release the revenue. I created the following measure:

 

MEASURE =

VAR Category = TABLE[Revenue Model Category]

VAR boolean_LicTypeOther = TABLE[License type]= "Other"

VAR boolean_LicTypePrptl = TABLE[License type] = "Perpetual"

VAR boolean_LicTypeFlex = TABLE[License type] = "Flex"

VAR boolean_Schuetz_Prptl_Core = TABLE[License type] = "Perpetual" && TABLE[Life cycle] = "New" && TABLE[Product type] = "Core Version"

VAR boolean_Module = TABLE[Product type] = "Module" && TABLE[License type] = "Perpetual"

VAR FOT_Adjusted = TABLE[FOT_Adjusted]

VAR UpgradeContract = TABLE[License type] = "Perpetual" && TABLE[Life cycle] = "Extended"

VAR boolean_serialno_Core = CALCULATETABLE(TABLE, ALL(TABLE[serialNumber], TABLE[Product type], TABLE[FOT_Convention]),TABLE[serialNumber] <> Blank (),TABLE[Product type] = "Core Version")

VAR boolean_serialno_Module = CALCULATETABLE(TABLE, ALL(TABLE[serialNumber], TABLE[Product type], TABLE[FOT_Convention]),TABLE[serialNumber] <> Blank (),TABLE[Product type] = "Module")

VAR boolean_serialno = CALCULATETABLE(TABLE, FILTER(TABLE, TABLE[serialNumber] <> Blank ()))

VAR boolean_fot_cv = LOOKUPVALUE(TABLE[Date], TABLE[serialNumber],  DISTINCTCOUNTNOBLANK([serialNumber]) , TABLE[Product type], "Core Version")

VAR boolean_fot_module = LOOKUPVALUE(TABLE[Date], TABLE[serialNumber], DISTINCTCOUNTNOBLANK([serialNumber]), TABLE[Product type], "Module")

VAR boolean_Module_New = TABLE[Product type] = "Module" && TABLE[Life cycle] = "New"

RETURN

    SWITCH (

            True,

            Category IN {"xx", "yy", "zz" },

                SWITCH (

                    TRUE,

                    boolean_LicTypeOther, 1,

                    boolean_LicTypePrptl, 12,

                    boolean_LicTypeFlex, 12,

                    boolean_Module_New && NOT ISBLANK (FOT_Adjusted), 12 - DATEDIFF(boolean_fot_module, boolean_fot_cv,  MONTH),

                        12),

            Category IN { "aa"},

                SWITCH (

                    TRUE,

                        boolean_Schuetz_Prptl_Core, 37,

                        boolean_Module && ISBLANK (Fot_Adjusted), 18,

                        boolean_LicTypeOther, 1,

                        boolean_Module && NOT ISBLANK (FOT_Adjusted) && TABLE[Life cycle] = "New", 37,

                        12),

            Category IN { "bb" },

                SWITCH (

                    TRUE,

                       UpgradeContract, 1,

                        48),

            Category IN { "cc" },

                SWITCH (

                    TRUE,

                        UpgradeContract || boolean_LicTypeOther, 1,

                        boolean_LicTypeFlex,  12,

                        1),

            Category IN { "dd" },

                SWITCH (

                    TRUE,

                        boolean_LicTypeOther || boolean_LicTypePrptl, 1,

                        12),

            BLANK ()

            )

I am not sure if I am on the right track, but I am getting nowhere. Now I get the typical message Function "'LOOKUPVALUE' does not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values." Since SerialNumber and Product type are both text, I assume the culprit is the date, but I do not know how to convert this actually. Does someone has an idea? And i searched this forum and the internet in general to no avail. 

Currently:

DateProduct TypeLIfe CycleSerialNumberMEASURE
02/01/2021Core VersionNew1234081512
01/01/2022ModuleNew1234081512
02/01/2022Core VersionExtended1234081512
02/01/2022ModuleExtended1234081512

 

Should be:

 

DateProduct TypeLIfe CycleSerialNumberMEASURE
02/01/2021Core VersionNew1234081512
01/01/2022ModuleNew123408151
02/01/2022Core VersionExtended1234081512
02/01/2022ModuleExtended1234081512

 

I also think that I have to consider the fact that the Core Version might be older than 1 year so I need the latest FOT_Convention date for this - if that makes sense. the result for the measure should be between 0 and 12.

Pls  let me know if you needf any additional information!

 

Thanks everyone!

11 Replies

  • v-janeyg-msft's avatar
    v-janeyg-msft
    Community Support

    Hi, GracieLeeMonroe 

     

    I checked your measure, trying to find the logic, I found that your code is very verbose, and the two codes of lookupvalue are indeed wrong, but I don't know what you want.

    So I need a complete and valid sample along with your calculation logic and expected results to help you modify measure. If you can provide, I'll help you streamline your code and modify it correctly.

     

    Best Regards,
    Community Support Team _ Janey

    • GracieLeeMonroe's avatar
      GracieLeeMonroe
      Frequent Visitor

      Hi v-janeyg-msft 

      thanks for your answer. I did not ignore you but was working on my huge excel files last week which actually are to be replaced by PowerBI. Regarding the sample, what exactly do you need? An extract from PowerBI in xls-format? I would need to remove/replace confidential data of course.....

      Thanks!

      Regards

      Angie

  • Hi v-janeyg-msft 

    I do understand, but it is company data and confidential, sorry.

    FOT is an abbreviation for First Online Time which defines for certain revenue streams the start of revenue recognition. There are several columns (FOT Adjusted, FOT_Convention) to adjust this date so it fits the needs - hope this helps. This file is generated each month and then imported into PowerBI.

    I do have License Type Perpetual, Flex and Other, Product Type Core Version, Core Version - Other, Module and Other. I do need a Core Version or Core Version Other at a minimum, then the customer can add Modules at any time, but the module follows the Core Version in terms of revenue recognition. The DAX formula I try to create should calculate this shorter revenue recognition period for modules added later in time. The Licenses (Perpetual and Flex) are split in License and Support, Support is deferred over 12 months. 

    I continued to work on my formula, but still do not get the result I want:

     

    VAR boolean_fot_cv = Calculate(MAX(IDL_Total[FOT_Convention]), Filter(IDL_Total,IDL_Total[serialNumber]<>BLANK() && IDL_Total[Product type] = "Core Version" ))
    VAR boolean_fot_module = Calculate(MIN(IDL_Total[FOT_Convention]), Filter(IDL_Total,IDL_Total[serialNumber]<>BLANK() && IDL_Total[Product type] = "Module" ))
     
    I am happy to share an excel file with you and any DAX Command for a calculated column/measure you need. But I would need to delete certain data (Customer Name, Product Name etc.) which I guess yo do understand.
     
    Regards
    Angie