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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Time function

Hello to all,

I am writing to you regarding a DAX request:

I have a table calculating the average electricity production according to a chosen period. This table is synchronized with two segments (Years and months) that allow me to choose the period I want to analyze.
What I would like to do is to add a column to this table that would calculate the average production of the current year (Year N). This would allow me to compare in the same table the values of previous years with the values of the current year.
The problem is that my segments take over my DAX query even when using an ALL function. Here is my query:

Moyenne corrigée année N (MWh) =
"AVERAGEX(
SUMMARIZE(
VALUES(Dates[Année]),
Dates[Année],
"E prod",
CALCULATE(SUM(fact_production[Energie produite (kWh)])/1000,fact_production[est_representatif]=TRUE(),YEAR(Dates[Année])=YEAR(TODAY()))
),
[E prod]
)"

As you can see below, I did not select the year 2021 so no result is displayed

image.png

If it helps, I have a relationship between a column in my date table and a column in my production table where the electricity production values are:

image.png

Thanks in advance for your help,

Have a nice day

Joël

 

1 ACCEPTED SOLUTION
PaulOlding
Solution Sage
Solution Sage

Is Moyenne corrigée periode (MWh) a measure that calculates what you want but for the selected time period instead of this year?

If so, does this work (where 'Year Column' is whatever you've used in the Periode prise en compte slicer) ?

 

Moyenne corrigée année N (MWh) =

CALCULATE(

[Moyenne corrigée periode (MWh)],

Dates[Year Column]=YEAR(TODAY())

)

View solution in original post

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

Is Moyenne corrigée periode (MWh) a measure that calculates what you want but for the selected time period instead of this year?

If so, does this work (where 'Year Column' is whatever you've used in the Periode prise en compte slicer) ?

 

Moyenne corrigée année N (MWh) =

CALCULATE(

[Moyenne corrigée periode (MWh)],

Dates[Year Column]=YEAR(TODAY())

)

Anonymous
Not applicable

Hello

Indeed it works, thank you very much @PaulOlding ! Sometimes you don't have to look too hard! ahahah

 

Have a nice day and thanks again

 

Bye

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors