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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Pitrus
Frequent Visitor

How can I use a value in a column as part of a formula?

Hi,

 

I would like to make this formula more generic and taking the value "W29" (or other weeks..) from a column that stores this info. W29 is indeed the table name and is present in column [Reporting Week] as well. Of course, we have many more tables for w28, w27 and so on

 

Original formula that works but is not mantainable:

 

SOH = IF([Reporting Week]="W29",CALCULATE(SUM(W29[Entr/bes.]),ALL(W29),W29[Dem/need]="Stock",W29[Article]=earlier('Material/week'[Material]), W29[Date2] <= EARLIER('Material/week'[date])) ...

 

What I try to do (in excelish terms, using INDIRECT)

 

SOH = CALCULATE(SUM(INDIRECT(earlier[Reporting Week]&[Entr/bes.]),ALL(INDIRECT(earlier[Reporting Week]),INDIRECT(earlier[Reporting Week]&[Dem/need]="Stock",INDIRECT(earlier[Reporting Week]&[Article]=earlier('Material/week'[Material]), INDIRECT(earlier[Reporting Week]&[Date2] <= EARLIER('Material/week'[date])) 

 

Is there any option to do this in DAX? 

 

Thanks in advance community!

 

3 REPLIES 3
amitchandak
Super User
Super User

@Pitrus , what are you trying to get here.

In case you are looking for  WOW data, refer

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

Thanks for the answer.

I am actually looking for referring a table name as a variable. Something like this:

 

SOH2 = 
VAR W=[Reporting Week]
RETURN
CALCULATE(SUM(W[Entr/bes.]),ALL(W),W[Dem/need]="Stock",W[Article]=earlier('Material/week'[Material]))

 

But it does not work 😞

Anonymous
Not applicable

This is NOT the way Power BI works. You can't have many tables, one for each week, and make it work. You have to arrive at one table with all the weeks in there.

Please first try to learn the basics of data modeling in dimensional models. There are many good vids on YT about this. Just search for it.

Best
D

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.