Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi Everyone! So close to having this figured out!
See the screenshot below.
Here are the formulas that I have:
Solved! Go to Solution.
@novotnajk
Use ALLSELECTED.
$ Cumulative Medical Spend =
VAR _CurrentDate =
MAX ( 'Reporting'[reporting_date] )
VAR _Calc =
CALCULATE (
[$ Medical Spend],
FILTER (
ALLSELECTED ('Reporting'),
'Reporting'[reporting_date] <= _CurrentDate
)
)
RETURN
_Calc
$ Cumulative SL Medical Spend =
VAR _CurrentDate =
MAX ( 'Reporting'[reporting_date] )
VAR _Calc =
CALCULATE (
[$ SL Medical Spend],
FILTER (
ALLSELECTED ( 'Reporting' ),
'Reporting'[reporting_date] <= _CurrentDate
)
)
RETURN
_Calc
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi @novotnajk
Here you go.
Running Total =
var _minDateCalc = CALCULATE(MIN(MedicalSpend[Reporting Date]),ALLSELECTED()) // This uses ALLSELECTED() and thus gets the minimum date based on the slicer
VAR _beginningDate =
MIN ( MedicalSpend[Reporting Date] )
VAR _currentDate =
MAX ( MedicalSpend[Reporting Date] )
Var _specialID = MAX(MedicalSpend[Special ID])
VAR _calc =
CALCULATE (
[Sum of Medical Spend],
ALL(MedicalSpend),
MedicalSpend[Reporting Date] <= _currentDate && MedicalSpend[Reporting Date]>= _minDateCalc,
MedicalSpend[Special ID]=_specialID
)
RETURN _calc+0
It was the beginning date that was the problem. The minimum date that was pulling before, was the minimum date on each row, which is why it did not total. The new var calculates the minimum date from the table based on the slicer because we use ALLSELECTED() and calculate it before we do the main calculation.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
Hi @novotnajk
Here you go.
Running Total =
var _minDateCalc = CALCULATE(MIN(MedicalSpend[Reporting Date]),ALLSELECTED()) // This uses ALLSELECTED() and thus gets the minimum date based on the slicer
VAR _beginningDate =
MIN ( MedicalSpend[Reporting Date] )
VAR _currentDate =
MAX ( MedicalSpend[Reporting Date] )
Var _specialID = MAX(MedicalSpend[Special ID])
VAR _calc =
CALCULATE (
[Sum of Medical Spend],
ALL(MedicalSpend),
MedicalSpend[Reporting Date] <= _currentDate && MedicalSpend[Reporting Date]>= _minDateCalc,
MedicalSpend[Special ID]=_specialID
)
RETURN _calc+0
It was the beginning date that was the problem. The minimum date that was pulling before, was the minimum date on each row, which is why it did not total. The new var calculates the minimum date from the table based on the slicer because we use ALLSELECTED() and calculate it before we do the main calculation.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Proud to be a Super User!
@novotnajk
Use ALLSELECTED.
$ Cumulative Medical Spend =
VAR _CurrentDate =
MAX ( 'Reporting'[reporting_date] )
VAR _Calc =
CALCULATE (
[$ Medical Spend],
FILTER (
ALLSELECTED ('Reporting'),
'Reporting'[reporting_date] <= _CurrentDate
)
)
RETURN
_Calc
$ Cumulative SL Medical Spend =
VAR _CurrentDate =
MAX ( 'Reporting'[reporting_date] )
VAR _Calc =
CALCULATE (
[$ SL Medical Spend],
FILTER (
ALLSELECTED ( 'Reporting' ),
'Reporting'[reporting_date] <= _CurrentDate
)
)
RETURN
_Calc
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
That didn't work. The values stayed the same. 😞
Should I change anything to the underlying measures within each?
@novotnajk
This is a new calculaton. what happened to the one you wanted to resolve in your first question?
Please share sample data and the expected results or show exactly what sort of problems you are facing in the calculation.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
There aren't any new calculations. The new ones that I posted are included in the original calculations as a measure. I changed the ALLSELECTED as recommended. Within this calculation is another measure called $ Medical Spend (and the other is $ SL Medical Spend).
The problem is that when I use the slicer to filter dates, the data from unfiltered spend is still part of the calculation and is carried over. Does that make sense?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
106 | |
75 | |
44 | |
39 | |
33 |
User | Count |
---|---|
165 | |
90 | |
65 | |
46 | |
43 |