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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
PeterS
Regular Visitor

Issue with group calculation / grouping

Dear Community,


I struggle with a code for days now. I have 4 columns in 1 table:

1. TIMESTAMP what is date/time type

2. QUESTIONID what is text type

3. ANSWER what is text type

4. SESSIONID what is text type


I would like to create a new column what contains a value from ANSWER column but only

- where the questionID is "14327",

- and I want to use this ANSWER value to every other row where SESSIONID is the same.

- Also It can happen that for the same sessionID there is more row what contain the mentioned questionid. In this case I want to use the answer where the TIMESTAMP is lower.


I used this code:

SHIFT =
VAR FilteredTable = FILTER(SHIFT_TABLE, [QUESTIONID] = "14327")
VAR GroupedTable =
GROUPBY(
FilteredTable,
[SESSIONID],
"EarliestTime", MINX(CURRENTGROUP(), [TIMESTAMP]),
"AnswerValue", FIRSTNONBLANK(FILTER(CURRENTGROUP(), [TIMESTAMP] = MINX(CURRENTGROUP(), [TIMESTAMP])), [ANSWER])
)
RETURN
LOOKUPVALUE(GroupedTable, [SESSIONID], [SESSIONID], "AnswerValue", [Answer])



 

I got the following error message: "Function LOOKUPVALUE expects a column reference as argument number 1." and also at the last line GroupedTable is underlined and if i move curson uppon it it write "Parameter is not the correct type

I tried many thing and modify the formula but just cannot find a solution.

 

Can anyone help what can be the problem or give suggestion for code modification?

 

Really thanks for help in advance!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@PeterS , first argument is return value

like

LOOKUPVALUE(GroupedTable[SESSIONID],  "AnswerValue", [Answer])

 

refer how can you get

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

 

within table, you can use the earlier

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@PeterS , first argument is return value

like

LOOKUPVALUE(GroupedTable[SESSIONID],  "AnswerValue", [Answer])

 

refer how can you get

refer 4 ways (related, relatedtable, lookupvalue, sumx/minx/maxx with filter) to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

 

 

within table, you can use the earlier

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8
https://www.youtube.com/watch?v=cN8AO3_vmlY&t=17820s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.