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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ebbrey
Frequent Visitor

SUMX with filter using SELECTEDVALUE

Hey

 

Im fairly new to Power BI and im trying to solve SUMX to a non-related table.

 

The table im trying to get correct number from has info like this:

Elements Table:

ProjectnumberCode2Start DateEnd DateDemand
1234567810.10.1001.01.201931.12.20196
1234567910.10.1115.07.201931.12.20196
9876543210.10.1001.01.201915.07.202012

 

In my visuals this table works great, since it filters on Project number. And i dont get issues at all. But i cant pull the data based on project number into power bi, I have to get this list with everything in it.

 

I have made a calendar that uses First date from Start Date and last date from End date. Then made new colums adding:

Calendar = CALENDAR([FirstDate];[LastDate])
Week = if(WEEKDAY('Calendar'[Date];2)=1;WEEKNUM('Calendar'[Date]);BLANK())
Year = 
year('Calendar'[Date])
Year-Week= IF('Calendar'[Week]<>BLANK();'Calendar'[YEAR]&"-"&'Calendar'[WEEK];Blank())
 
Then i removed blank() rows in Week. I need a new column into this calendar table that pulls Demand from elements table so i can show the weeks and what the demand is in that week for the current selected project.

I have tried this so far for a new column:
 
Demand =
IF('Calendar'[Year-Week]=BLANK();BLANK();
CALCULATE(
sumx(filter('Elements';Elements[Projectnumber]="12345678");Elements[Demand]);
'Elements'[Start Date] <= EARLIER ( 'Calendar'[Date] );
'Elements'[End Date] >= EARLIER ( 'Calendar'[Date] )))

1.png
 
This works. But not based on the current selected project. As i have written the number in. 
 
i wish this worked:
 
Demand =
IF('Calendar'[Year-Week]=BLANK();BLANK();
CALCULATE(
sumx(filter('Elements';Elements[Projectnumber]=SELECTEDVALUE(Projectlist[Number]));Elements[Demand]); 
'Elements'[Start Date] <= EARLIER ( 'Calendar'[Date] );
'Elements'[End Date] >= EARLIER ( 'Calendar'[Date] )))
 
Thanks for any input on how to solve this.
1 ACCEPTED SOLUTION
lc_finance
Solution Sage
Solution Sage

Hi @ebbrey ,

 

 

To have the measure based on the currently selected project, you'd need to use a calculated measure instead of a calculated column.

Does this help you?

 

If it doesn't, can you share a sample Power BI file?

You can share it via One Drive, Google Drive or a similar tool.

 

Regards,

 

LC

Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com

View solution in original post

3 REPLIES 3
lc_finance
Solution Sage
Solution Sage

Hi @ebbrey ,

 

 

To have the measure based on the currently selected project, you'd need to use a calculated measure instead of a calculated column.

Does this help you?

 

If it doesn't, can you share a sample Power BI file?

You can share it via One Drive, Google Drive or a similar tool.

 

Regards,

 

LC

Interested in Power BI and DAX templates? Check out my blog at www.finance-bi.com

@lc_finance 

 

Thanks for your reply to my question and pointing me away from trying to use selectedvalue in a column.

 

I ended up getting it to work by using a referance table wich i could relate to the project table and get the filter i needed.

I'm glad you found a solution for it!

 

Do not hesitate if you have more questions.

 

LC

Interested in Power BI and DAX tutorials? Check out my blog at www.finance-bi.com

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.