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
PowerBI_AL2022
Regular Visitor

error in calling the defined definition in variable in a measure

Hi All, 

 

i am stuck in recgnizing the error in this measure , kindly anyone please help me out..

 

MAX_QTY_SKU3 Test 1 =
VAR _VW_DESIGNITEM_DS6_IS6_SUMMARIZED =
    SUMMARIZECOLUMNS (
        VW_DESIGNITEM_DS6_IS6[NAME],
        "CATALOG", DISTINCTCOUNT(VW_DESIGNITEM_DS6_IS6[PARTITIONKEY]),
        "ADDS", SUM(VW_DESIGNITEM_DS6_IS6[QUANTITY])
    )
VAR _AddRank =
    ADDCOLUMNS (
        _VW_DESIGNITEM_DS6_IS6_SUMMARIZED,
        "Rank", RANKX (_VW_DESIGNITEM_DS6_IS6_SUMMARIZED, [ADDS],, DESC, DENSE)
    )
VAR _qty = TOPN(1,_AddRank,[Rank],ASC)
RETURN SELECTCOLUMNS(_qty,[CATALOG])
 
CATALOG in this measure is showing error mark nd even the results are not summing up well..
 
thanks in advance 🙂
2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @PowerBI_AL2022 

 

The SELECTCOLUMNS function returns a calculated table, not a measure. 

SELECTCOLUMNS function (DAX) - DAX | Microsoft Learn
You can try :

RETURN SUMX(_qty,[CATALOG])

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

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

Thank you so much for your response.

I tried your suggestion i.e. using SUMX instead of SELECTCOLUMNS but it still seem not to be working.

 

Attaching the image for reference :

PowerBI_AL2022_0-1701778146234.png

 

here the highlighted 2 KPIs in yellow are the ones which have issues , 

KPI result 37.06% uses the formula "DIVIDE([MAX_QTY_SKU3],[Projects])+0"

 

and MAX_QTY_SKU3 uses the calculation as show below:

MAX_QTY_SKU3  =
VAR _VW_DESIGNITEM_DS6_IS6_SUMMARIZED =
    SUMMARIZECOLUMNS (

        VW_DESIGNITEM_DS6_IS6[NAME],

        "CATALOG", DISTINCTCOUNT(VW_DESIGNITEM_DS6_IS6[PARTITIONKEY]),

        "ADDS", SUM(VW_DESIGNITEM_DS6_IS6[QUANTITY])

    )
VAR _AddRank =

    ADDCOLUMNS (

        _VW_DESIGNITEM_DS6_IS6_SUMMARIZED,

        "Rank", RANKX (_VW_DESIGNITEM_DS6_IS6_SUMMARIZED, [ADDS],, DESC, DENSE)

    )

VAR _qty = TOPN(1,_AddRank,[Rank],ASC)

RETURN SELECTCOLUMNS(_qty,[CATALOG]) 
 
the problem here is when any bar in the chart is selected , the KPI s donot show any result and displays an error message like this ..
 
PowerBI_AL2022_1-1701778467818.png

 

so i am unable to find out whats the issue here , 

 

the connection between the tables used in the bar chart and KPI s are well defined in the data model so there is no issue there.

 

i also tried to change the function used in the measure as you suggested but it didnt work .

 

please guide me in anyway possible , it would be really helpfull .

Thanks for your time and knowledge.

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.