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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rauerfc
Frequent Visitor

Summarize and Addcolumn related with DAX

Hello,

 

I need to calculate the average of percentages in a table:

 

anexo1.png

 

in order to do this i used this measure:

 

perc_rel = 
VAR perc_relacao = CALCULATE(SUM(Table_output[Peso_total]))/[somw_total]
VAR semana = SELECTEDVALUE(Table_output[Week])
RETURN
IF (HASONEFILTER(Table_output[mes_remessa].[Month]);
    perc_relacao;CALCULATE(AVERAGEX(indicador_semana;indicador_semana[Column]);FILTER(indicador_semana;indicador_semana[Week]=Semana)))

But, when the data it's filtered with Plant, the total doesn't recalculate:

 

anexo2.png

 

As u can see the percentage of Week by month change but the total remains the same, except when we don't have a value by month, the case of W3.

Then I've created another measure:

Two SUMMARIZE tables one with the denominator "denominador" and another with numerator "numerador". It's is possible to divide one for another with [mes_remessa].[month] as a key value of intersection between the two Variables "denominador" and  "numerador"? 

perc_rel = 
VAR perc_relacao = CALCULATE(SUM(Table_output[Peso_total]))/[somw_total]
VAR denominador = SUMMARIZE(Table_output;Table_output[mes_remessa].[Month];"denom";SUM(Table_output[Peso_total]))
VAR numerador = SUMMARIZE(Table_output;Table_output[mes_remessa].[Month];Table_output[Week];"nume";SUM(Table_output[Peso_total]))
VAR sp_matriz = ADDCOLUMNS(numerador;"indicador";[nume]/CALCULATE(SUMX(denominador;[denom]);FILTER(numerador;[mes_remessa].[Month]=(FILTER(denominador;[mes_remessa].[Month])))))
VAR semana = SELECTEDVALUE(Table_output[Week])

RETURN
IF (HASONEFILTER(Table_output[mes_remessa].[Month]);
    perc_relacao;CALCULATE(AVERAGEX(sp_matriz;[indicador]);FILTER(Table_output;[Week]=semana)))

 

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @rauerfc ,

I'm still a little confused about your scenario.

To understand your requirement better, could you share some data sample as table format and your desired output so that we could have a test on it?

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-piga-msft ,

 

Basically i'm calculating the weight on the week divided by the weight of the month, and the total on the "dashboard table" is the average of their percentages by month. When I filter by Plant ("Fábrica") the average total doesn't recalculate. 

Desire output:

SUM(Weight of Week "1" on January)/SUM(Weight on January) %

SUM(Weight of Week "2" on February)/SUM(Weight on February) %

SUM(Weight of Week "3" on March)/SUM(Weight on March) %

Total = Average of this percentages @v-piga-msft 

anexo3.png

See the table below:

YearPlantMonthWeekWeightDateConcat
2019PMRI9W11299,69501/09/2019W1September
2019PMRI9W21462,35401/09/2019W2September
2019FACF10W1901,00501/10/2019W1October
2019LDCI9W42961,65801/09/2019W4September
2019PACI11W18665,75601/11/2019W1November
2019PACI9W18665,75601/09/2019W1September
2019BMCI10W13739,29101/10/2019W1October
2019PACI10W18665,75601/10/2019W1October
2019PACI10W35548,82501/10/2019W3October
2019PACI12W18665,75601/12/2019W1December
2019BMCI12W13739,29101/12/2019W1December
2019PACI9W41743,09501/09/2019W4September
2019PACI10W41743,09501/10/2019W4October
2019BMCI9W13739,29101/09/2019W1September
2019BMCI10W41555,72201/10/2019W4October
2019LDCI10W42961,65801/10/2019W4October
2019PACI11W35548,82501/11/2019W3November
2019PACI12W35548,82501/12/2019W3December
2019PACI10W24448,17901/10/2019W2October
2019LDCI11W42961,65801/11/2019W4November
2019VLCI10W473,60201/10/2019W4October
2019VLCI11W473,60201/11/2019W4November
2019VLCI10W362,52601/10/2019W3October
2019LDCI9W38200,93501/09/2019W3September
2019PECI9W384,89301/09/2019W3September
2019PECI10W384,89301/10/2019W3October
2019PECI11W4147,70801/11/2019W4November
2019PMCI12W11182,98201/12/2019W1December
2019PMRI11W4946,72101/11/2019W4November
2019PECI10W2203,62901/10/2019W2October
2019PMCI9W11182,98201/09/2019W1September
2019VLCI9W362,52601/09/2019W3September
2019VLCI9W1143,14301/09/2019W1September
2019VLCI10W2191,50401/10/2019W2October
2019BMCI10W37783,26101/10/2019W3October
2019BMCI11W41555,72201/11/2019W4November
2019BMCI12W37783,26101/12/2019W3December
2019BMCI11W21057,27901/11/2019W2November
2019BMCI12W21057,27901/12/2019W2December
2019VLCI9W2191,50401/09/2019W2September
2019PECI9W2203,62901/09/2019W2September
2019VLCI12W473,60201/12/2019W4December
2019PECI9W4147,70801/09/2019W4September
2019PECI9W1148,46401/09/2019W1September

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.