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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

How to get select column1 from table where column2 = xyz in a table variable to reuse it?

I wanted to do achieve this “sql” code in a DAX variable

 

Select WeekYearWeekNumber from DimDate where Date = today()+7

 

 

How can achieve it?

 

 

 

So far I have this code, but the last line doesn’t work because nextw is more than a column…

var nextw =

FILTER(

            SUMMARIZE('Date','Date'[Week Year Week Number],'Date'[Date]) ,                      

                        'Date'[Date]=TODAY()+7

                         )





var NextWCS =

FILTER(

            SUMMARIZE(Staff,   Staff[K_Emp],   Staff[StaffingType],  'Date'[Week Year Week Number],   Staff[IsTmed],

                         "sumat", SUM(Staff[Hours])

                         ),                      

                        'Date'[Week Year Week Number]=nextw

                         )

 

1 ACCEPTED SOLUTION
ValtteriN
Community Champion
Community Champion

Hi,

SELECTCOLUMNS is one way to do this:

Next 7 days date = SELECTCOLUMNS(FILTER('Calendar','Calendar'[Date]=TODAY()+7),"Date",'Calendar'[Date])
 
End result:
 
ValtteriN_0-1641827148849.png


I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
PaulOlding
Solution Sage
Solution Sage

Hi @Anonymous 

This will give you a scalar that you can then use in NextWCS

Nextw = 
CALCULATE(
    SELECTEDVALUE('Date'[Week Year Week Number]),
    'Date'[Date] = TODAY() + 7
)
smpa01
Community Champion
Community Champion

@Anonymous  what are you exactly trying to achieve? provide sample data and expected output?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
ValtteriN
Community Champion
Community Champion

Hi,

SELECTCOLUMNS is one way to do this:

Next 7 days date = SELECTCOLUMNS(FILTER('Calendar','Calendar'[Date]=TODAY()+7),"Date",'Calendar'[Date])
 
End result:
 
ValtteriN_0-1641827148849.png


I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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