Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I have the following data model
data model
The following table shows Wind_Generation:
wind generation
I am trying to sum all of 'facilities_wind'[Generator Capacity] per 'calendar'[Date].
How do I solve the problem without turning the cross-filter direction between 'facilities' and 'Wind' to both?
(trying to learn DAX) :^)
Solved! Go to Solution.
Ha! Solved it, thanks to @Anonymous, my tenacity and this post: Context transition
The Measure must be written like the following:
M100 =
VAR GenCpctyMWh = SUMX (
ADDCOLUMNS (
'calendar',
"@CpctyDay", CALCULATE(SUM('facilities_wind'[Generator Capacity (MW)]), RELATEDTABLE(Wind_Generation))
),
[@CpctyDay]*('calendar'[Hours_Day])
)
VAR GenDaily = CALCULATE(SUM('Wind_Generation'[Value]))
RETURN 100 * DIVIDE(GenDaily, GenCpctyMWh)
@Anonymous , facilities_wind is a fact on many sides and will get filtered from date, that does not need cross direction
if you these dimension slicer to filter each other check
The table below shows the correct results when I cross-filter both ways.
correct results by cross-filtering both ways
where Column 5 = Column 2 / Column 4.
I figured out how to replicate that table when switching to cross-filter one way.
I just need to use the Date column from 'Wind_generation', not 'calendar' , and connect them with RELATED.
However, I am failing to replicate Column 5:
Column 5 incorrect
Formula for column 5 is
MEASURE CapacityFactor% =
VAR GenCpcty = SUMX('Wind_Generation','facilities_wind'[MEASURE_GeneratorCpcty])
VAR GenCpctyMWh = SUMX('Wind_Generation',GenCpcty * RELATED('calendar'[Hours_Day]))
VAR ActualGen = CALCULATE(SUM('Wind_Generation'[Value]))
RETURN 100*DIVIDE(ActualGen, GenCpctyMWh)
But when I calculate the measures separately, like the following,
Measure = SUMX('Wind_Generation','facilities_wind'[MEASURE_GeneratorCpcty])
Measure 2 = SUMX('Wind_Generation',[Measure] * RELATED('calendar'[Hours_Day]))
Measure 3 = CALCULATE(SUM('Wind_Generation'[Value]))
Measure 4 = 100 * DIVIDE([Measure 3], [Measure 2])
it works!!
column 6
How can that be?!! The formulas are the same, except that the first one keeps all the measures as VARs.
What's going on?
Hi @Anonymous ,
Believe it's something with Row context and filter context.
For example:
measure1 = rankx('table',sum(value))
measure2 = rankx('table',calculate(sum(value)))
tmp = sum(value)
measure3 = rankx('table',[tmp])
measure1<>measure2&&measure3
Measure2=measure3
Hope this blog helps.
https://blog.enterprisedna.co/row-context-and-filter-context-in-a-power-bi-dax-code/
Best Regards,
Jay
So I tried something that I saw on that link.
When I externalise the 2nd variable, it works.
wrong result
This works
Ha! Solved it, thanks to @Anonymous, my tenacity and this post: Context transition
The Measure must be written like the following:
M100 =
VAR GenCpctyMWh = SUMX (
ADDCOLUMNS (
'calendar',
"@CpctyDay", CALCULATE(SUM('facilities_wind'[Generator Capacity (MW)]), RELATEDTABLE(Wind_Generation))
),
[@CpctyDay]*('calendar'[Hours_Day])
)
VAR GenDaily = CALCULATE(SUM('Wind_Generation'[Value]))
RETURN 100 * DIVIDE(GenDaily, GenCpctyMWh)
Hey, @amitchandak,
I was wondering if it's possible to write a measure without the aid of a slicer.
When I apply cross-filtering both ways, the measure
MEASURE_GeneratorCpcty = CALCULATE(SUM('facilities_wind'[Generator Capacity (MW)]))gives the correct result:
correct result
If I switch to one-way filtering, then I get the wrong result:
wrong result
How can I rewrite the MEASURE with one-way filtering?
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |