This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi all,
I have a problem. I want to create a dynamic measure in DAX that will depend of the name of the variable.
I have a table with column names display like this Month 1, Month 2,..... Month n, now depending of the current month or the selected month , the formula will display the value of the month selected and the one of the previous month. I want a formula like this SUM(Month n) + SUM (Month n-1). This is possible in Excel using INDIRECT function, what about DAX!!!!
Thank you
Hi. did you find a DAX function similar to "indirect" in Excel? I've been search the net but no success yet. Would appreciate your feedback.
Hi,
Assuming you have a Calendar table with Year and Month columns in there, build a relationship from the Date column of your Data Table to the Date column of the Calendar Table. Create 2 slicers - one for Year and another for Month - select any one Year and Month. Write these measures
Total = SUM(Data[Amount])
Total for this and previous month = CALCULATE([Total],DATESBETWEEN(Calendar[Date],EDATE(MIN(Calendar[Date]),-1),MAX(Calendar[Date])))
Hope this helps.
Hi @Anonymous ,
I'm assuming that your data is on the format like below:
| KPI | 1 | 2 | 3 | 4 | 5 | 6 |
| Value | 1 | 1 | 1 | 1 | 1 | 1 |
If this is the case believe that the best option is to unpivot the table and have something like this:
| KPI | Month | Value |
| Value | 1 | 1 |
| Value | 2 | 2 |
| Value | 3 | 3 |
| Value | 4 | 4 |
| Value | 5 | 5 |
| Value | 6 | 6 |
Then you can create a measure similar to this:
Total 2 month =
CALCULATE ( SUM ( Table1[Value] ) )
+ CALCULATE (
SUM ( Table1[Value] );
FILTER ( ALL ( Table1[Month] ); Table1[Month] = ( MAX ( Table1[Month] ) - 1 ) )
)
If you don't want to unpivot your columns then you need to do it using several measures and a switch function.
Can you share a sample of you data and expected result.
thank you.
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsCheck out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 35 | |
| 32 | |
| 25 | |
| 22 | |
| 18 |
| User | Count |
|---|---|
| 66 | |
| 36 | |
| 32 | |
| 25 | |
| 23 |