Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I was tasked to make some python visualizations with this dax code:
Inclusion_Expected =
VAR _item_number = Source_With_Trace_ID[Item_Number]
VAR _cast_date = Source_With_Trace_ID[Casting_Date]
VAR _start_date = _cast_date - 365
VAR _inclusions =
CALCULATE(
SUM(Source_With_Trace_ID[Inclusion]),
FILTER(Source_With_Trace_ID,
Source_With_Trace_ID[Item_Number] = _item_number
&& Source_With_Trace_ID[Casting_Date] >= _start_date
&& Source_With_Trace_ID[Casting_Date] < _cast_date
)
)
VAR _closed =
CALCULATE(
SUM(Source_With_Trace_ID[Closed]),
FILTER(Source_With_Trace_ID,
Source_With_Trace_ID[Item_Number] = _item_number
&& Source_With_Trace_ID[Casting_Date] >= _start_date
&& Source_With_Trace_ID[Casting_Date] < _cast_date
)
)
VAR _inclusion_scrap_rate = DIVIDE(_inclusions, _closed)
RETURN _inclusion_scrap_rate
I think I understand it, but when trying to translate it over I'm getting different results.
First in the filter statement, does
@JBennett12 It is doing something because of how CALCULATE replaces filtering context and the fact that you are operating essentially in the context of ALL when you are doing those CALCULATE statements. The variables at the beginning are just preserving the row context that you want to use later. You can think of the first CALCULATE statement like the following:
SUMX(
FILTER(
ALL('Source_With_Trace_ID'),
[Item_Number] = _item_number
&& [Casting_Date] >= _start_date
&& [Casting_Date] < _cast_date
),
[Inclusion]
)
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
114 | |
95 | |
90 | |
35 | |
35 |
User | Count |
---|---|
154 | |
102 | |
82 | |
64 | |
54 |