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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

adjusting DAX measure for opening balance

Would someone please tell me how I can edit the following DAX:
 
Total Budget per ZP =

var Planned_budget = SUM(DIA_PBI_SAP_ZEITPROJECTAUFGABEN[projectitembudgettime])
var minSelectedDate = MIN('Date'[Date])
var raportiertezeit = sum(DIA_SAP_LEISTUNGEN_AUS_SAP[dauerdezimal])
var AllActualWorkDoneBeforeCurrentDate =
CALCULATE(
SUM(DIA_SAP_LEISTUNGEN_AUS_SAP[Verrechenbar1]),
FILTER(ALL('Date'[Date]), [Date] < minSelectedDate), ALL(DIA_SAP_LEISTUNGEN_AUS_SAP[AufgabeCode], DIA_SAP_LEISTUNGEN_AUS_SAP[Externe/Interne]), ALL(Artikelkategorien[Pauschal/Aufwand])
)
return
if (raportiertezeit <> BLANK(),Planned_budget-AllActualWorkDoneBeforeCurrentDate)
 
 
This is the result I'm getting in Power BI (it does the calculation correctly, but only at the beginning of each month):
 
Nigel_Mayhew_1-1609409997276.png

 

 
I need it to show me the 'Total Budget per ZP' value/column as follows (the calculation should happen line by line, in a chronological order):
 
 
JahrCalendar MonthnummerAufgabeCodePauschal/AufwandExterne/InterneTotal Project BudgetTotal Budget per ZPEröffnung BudgetdauerdezimalVerrechenbarNicht VerrechenbarAbschluss Budget
2017Dec283058552PauschalExterne346346524.54.5047.5
2017Dec283058553PauschalExterne346341.5941212082
2018Jan283058552PauschalExterne346329.547.51.251.25046.25
2018Jan283058553PauschalExterne346328.258228.2527.50.7554.5
2018Jan283058556PauschalExterne346300.75121.51.5010.5
2018Feb283058552PauschalExterne346299.2546.251.51.5044.75
2018Feb283058553PauschalExterne346297.7554.50.50.5054
2018Feb283058555PauschalExterne346297.25761212064
2018Feb283058556PauschalExterne346285.2510.50.7500.7510.5
2018Mar283058552PauschalExterne346285.2544.754.54.5040.25
2018Mar283058556PauschalExterne346280.7510.56604.5
2018Apr283058552PauschalExterne346274.7540.2522038.25
2018Apr283058553PauschalExterne346272.755413.75121.7542
2018May283058553PauschalExterne346260.75421.251.25040.75
2018May283058556PauschalExterne346259.54.50.250.2504.25
2018Jun283058553PauschalExterne346259.2540.7533037.75
2018Aug283058554PauschalExterne346256.251128.258.250103.75
2018Sep283058554PauschalExterne346248103.755.55.5098.25
2018Oct283058554PauschalExterne346242.598.2537.25343.2564.25
2018Nov283058554PauschalExterne346208.564.2517.517.5046.75
2018Dec283058554PauschalExterne34619146.7544042.75
2019Feb283058554PauschalExterne34618742.759.259.25033.5
2019Feb283058556PauschalExterne346177.754.251.751.7502.5
2019Mar283058554PauschalExterne34617633.53231.50.52
2019Apr283058554PauschalExterne346144.522200
2019Sep283058554PauschalExterne346142.505.755.250.5-5.25
So, the only filter that should apply is the Project Number ('nummer') in column 3.
 
Looking forward to your response.
 
Thanks.
4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Assuming you date in the table , based on sample try a measure like

 

sum(Table[Total Project Budget]) - calculate(sum(Table[dauerdezimal]), filter(all(Table), Table[Date] <=max(Table[Date])))

 

or

 

sum(Table[Total Project Budget]) - calculate(sum(Table[dauerdezimal]), filter(allselected(Table), Table[Date] <=max(Table[Date])))

Anonymous
Not applicable

Hi,

 

Neither of them works I'm afraid.

 

Can you please make an adjustment to my current DAX?:

 

Total Budget per ZP =

 

var Planned_budget = SUM(DIA_PBI_SAP_ZEITPROJECTAUFGABEN[projectitembudgettime])

var minSelectedDate = MIN('Date'[Date])

var raportiertezeit = sum(DIA_SAP_LEISTUNGEN_AUS_SAP[dauerdezimal])

var AllActualWorkDoneBeforeCurrentDate =

CALCULATE(

SUM(DIA_SAP_LEISTUNGEN_AUS_SAP[Verrechenbar1]),

FILTER(ALL('Date'[Date]), [Date] < minSelectedDate), ALL(DIA_SAP_LEISTUNGEN_AUS_SAP[AufgabeCode], DIA_SAP_LEISTUNGEN_AUS_SAP[Externe/Interne]), ALL(Artikelkategorien[Pauschal/Aufwand])

)

return

if (raportiertezeit <> BLANK(),Planned_budget-AllActualWorkDoneBeforeCurrentDate)

 

BTW, i am using a date from a dedicated date table: 'Date'[Date]

 

Looking forward to hearing back from you.

 

Many thanks.

Change your code to this...

var Planned_budget = SUM(DIA_PBI_SAP_ZEITPROJECTAUFGABEN[projectitembudgettime])
var maxSelectedDate = MAX('Date'[Date])
var raportiertezeit = sum(DIA_SAP_LEISTUNGEN_AUS_SAP[dauerdezimal])
var AllActualWorkDoneBeforeCurrentDate =
CALCULATE(
SUM(DIA_SAP_LEISTUNGEN_AUS_SAP[Verrechenbar1]),
FILTER(ALL('Date'[Date]), [Date] < maxSelectedDate), ALL(DIA_SAP_LEISTUNGEN_AUS_SAP[AufgabeCode], DIA_SAP_LEISTUNGEN_AUS_SAP[Externe/Interne]), ALL(Artikelkategorien[Pauschal/Aufwand])
)
return
if (raportiertezeit <> BLANK(),Planned_budget-AllActualWorkDoneBeforeCurrentDate)
Anonymous
Not applicable

Hi @littlemojopuppy 

 

Thanks for your response.

 

Unfortunately, it still doesn't work.

 

This is the result of your DAX:

 

Nigel_Mayhew_0-1609751839581.png

 

 

Here is how it should be: 

Jahr

Calendar Month

nummer

AufgabeCode

Pauschal/Aufwand

Externe/Interne

Total Project Budget

Total Budget per ZP

Total Budget per ZP2

Should be

dauerdezimal

Verrechenbar

2017

Dec

2830

58552

Pauschal

Externe

346

346

329.5

346

4.5

4.5

2017

Dec

2830

58553

Pauschal

Externe

346

346

329.5

341.5

12

12

2018

Jan

2830

58552

Pauschal

Externe

346

329.5

299.25

329.5

1.25

1.25

2018

Jan

2830

58553

Pauschal

Externe

346

329.5

299.25

328.25

28.25

27.5

2018

Jan

2830

58556

Pauschal

Externe

346

329.5

299.25

300.75

1.5

1.5

2018

Feb

2830

58552

Pauschal

Externe

346

299.25

285.25

299.25

1.5

1.5

2018

Feb

2830

58553

Pauschal

Externe

346

299.25

285.25

297.75

0.5

0.5

2018

Feb

2830

58555

Pauschal

Externe

346

299.25

285.25

297.25

12

12

2018

Feb

2830

58556

Pauschal

Externe

346

299.25

285.25

285.25

0.75

0

2018

Mar

2830

58552

Pauschal

Externe

346

285.25

274.75

285.25

4.5

4.5

2018

Mar

2830

58556

Pauschal

Externe

346

285.25

274.75

280.75

6

6

2018

Apr

2830

58552

Pauschal

Externe

346

274.75

260.75

274.75

2

2

2018

Apr

2830

58553

Pauschal

Externe

346

274.75

260.75

272.75

13.75

12

2018

May

2830

58553

Pauschal

Externe

346

260.75

259.25

260.75

1.25

1.25

2018

May

2830

58556

Pauschal

Externe

346

260.75

259.25

259.5

0.25

0.25

2018

Jun

2830

58553

Pauschal

Externe

346

259.25

256.25

259.25

3

3

2018

Aug

2830

58554

Pauschal

Externe

346

256.25

248

256.25

8.25

8.25

2018

Sep

2830

58554

Pauschal

Externe

346

248

242.5

248

5.5

5.5

2018

Oct

2830

58554

Pauschal

Externe

346

242.5

208.5

242.5

37.25

34

2018

Nov

2830

58554

Pauschal

Externe

346

208.5

191

208.5

17.5

17.5

2018

Dec

2830

58554

Pauschal

Externe

346

191

187

191

4

4

2019

Feb

2830

58554

Pauschal

Externe

346

187

177

187

9.25

9.25

2019

Feb

2830

58556

Pauschal

Externe

346

187

177

177.75

1.75

1.75

2019

Mar

2830

58554

Pauschal

Externe

346

176

144.5

176

32

31.5

2019

Apr

2830

58554

Pauschal

Externe

346

144.5

142.5

144.5

2

2

2019

Sep

2830

58554

Pauschal

Externe

346

142.5

137.25

142.5

5.75

5.25

 

So the idea is that we should take the 'Total Project Budget' figure and subtract all 'Verrechenbar' values from previous line/row (the focus should be on the calculation performing row by row, because sometimes we would have more than one entry in the same period, as is the case above for Dec 2017/Jan 2018 etc.).

 

Is this something doable

 

Cheers.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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