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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Joshmarsteffens
Frequent Visitor

Storing multiple value's in a variable?

Hello,

 

I have a question regarding datamanipulation. I am trying to get data from 'Leenotification' to 'KPI sociale doelstellingen' however this must be linked by its Complex/Kavel ID. Meaning there will be multiple numbers returned through the lookupvalue() function (this is the case because 'KPI sociale doelstelling' is linked with 'data_WBS_tbv_beleidsp.' through kavel/object id which is a one on one relation, the same goes for the relation between 'woning_overzicht' and 'data_WBS_tbv_beleidsp.' however from 'woning_overzicht' to 'PMEOBJECT' is a one to many relation ship).

 

But i can not use a count() to count it since count() only counts columns and not variable numbers. Also im not even certain if a variable can contain multiple values in DAX syntax. Is there maybe an array varriable that I could use? Anyways I had come up with this syntax but it gives me nothing as a result.

Hoeveelheid overlastmeldingen = var connectionDataWBS = LOOKUPVALUE(Data_WBS_tbv_Beleidsportaal[Uniek nummer]; Data_WBS_tbv_Beleidsportaal[Uniek nummer]; 'KPI sociale doelstelling'[Kavel ID])
var connectionWoningOverzicht = LOOKUPVALUE(Woning_overzicht[complex]; Woning_overzicht[complex]; connectionDataWBS)
var connectionPMEOBJECT = LOOKUPVALUE(PMEOBJECT[OBJECTID]; PMEOBJECT[COMPLEXID]; connectionWoningOverzicht)
var connectionLEENOTIFICATION = LOOKUPVALUE(LEENOTIFICATION[NOTIFICATIONID]; LEENOTIFICATION[OBJECTID]; connectionPMEOBJECT )
return
connectionLEENOTIFICATION

 

(From variable connectionPMEOBJECT it already returns BLANK() values since it starts there with the one to many relationship)

 

This probably has to do with the fact that im trying to store multiple value's in a variable. I would want to set it in an new column to temporary store those values however I need those still to be linked to the Complex/Kavel ID meaning I would still get multiple values in a variable.

 

I hope that someone could help me with this one.

 

Greetings,

 

Joshmar Steffens

 

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Joshmarsteffens,

>>But i can not use a count() to count it since count() only counts columns and not variable numbers.

You can use COUNTA function, which counts the number of cells in a column that are not empty. 

A variable can include a simple table, just like the following example DAX formula.

[RedSalesLastYear] :=
VAR
    RedProducts = FILTER (
        ALL ( Product[Color] ),
        Product[Color] = "Red"
    )
VAR
    LastYear = SAMEPERIODLASTYEAR ( 'Date'[Date] )
RETURN
    CALCULATE ( SUM ( Sales[Quantity] ), RedProducts, LastYear )


For your requirement, it's difficult to include mutiple values, because the rows returned by LOOKUPVALUE are different.

Best Regards,
Angelia

Hi @Joshmarsteffens,

Have you resolved your issue? If you have, please mark corresponding reply as answer, and welcome to share your own solution. 

If you have other problem, please feel free to ask.

Best Regards,
Angelia

Hello @v-huizhn-msft,

 

Sadly this has not fixed my issue 

 

The problem I have is, that I have a distinct id in the target table however the data I get comes from a table that doesnt have distinct numbers on that same column. (so the columns used in the condition for the LOOKUPVALUE())

 

The result of this is that when you have ID 1 it may or may not return 6, 92, 199 ,32 but what i would want it to return is 4, the count of the results.

 

However I can't use ANY of the counts as it will just result in an error saying that it needs a column or an table or rows to be able to count. I can not use any of the counts over an varriable.

 

 

A collega of mine came with an sollution. In my case the SUMMARIZE() function can be used here to get the results I wanted to see.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.