DAX Filter Context - Powerbi

Asked

Viewed 70 times

2

I have a simple spreadsheet for fuel supply control

3 columns: Date of filling KM Car Plate on odometer at the time of filling.

I want to set up a measurement to know how much was driven in KM

For this you needed to take the Largest KM - the smallest KM for each PLATE(different car) and add it all up.

Problem is, I can’t break down by car within measure, unless I explain it by filtering car by car. However other cars can be registered, and it will not be possible to update the measure.

If I use that measure here:

KM Wheelset = CALCULATE(SUM(ftAbastecimentos[Km]),LASTDATE(ftAbastecimentos[Date of supply])-CALCULATE(SUM(ftAbastecimentos[Km]),FIRSTDATE(ftAbastecimentos[Date of supply]))

I use the date column to catch the KM in the smallest and longest date that appear, subtract and add.

If I place this measure on a table together with the column board, the result appears for each board in the right way. I needed to find a way to add up those values.

  • If the answer was helpful, remember to mark it as correct.

1 answer

1

I do not know if I understand well, I understand that you want to know a total value, regardless of whether there is filter applied to a vehicle. In this case, it is necessary, within the formula DAX, to remove the filter with the function ALL ().

For example:

KM rodado = 
VAR KM_INICIALES = CALCULATE (SUM (ftSupplements [Km]), LASTDATE (ftSupplements [Fecha de suministro]), ALL(ftSupplements)) 
VAR KM_FINALES = CALCULATE (SUM (ftSupplements [Km]), FIRSTDATE (ftSupplements [Fecha de suministro]), ALL(ftSupplements))

RETURN
KM_FINALES  - KM_INICIALES

Browser other questions tagged

You are not signed in. Login or sign up in order to post.