March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Let this dataset be a small reproducible example.
(Update: I've also created a column MonthYear which transforms e.g. 06/01/2018 to June-2018)
Date | Value | Type |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | Gross Margin |
06/01/2018 | 100 | B |
06/01/2018 | 100 | B |
06/01/2018 | 100 | B |
06/01/2018 | 100 | C |
06/01/2018 | 100 | C |
07/01/2018 | 100 | Gross Margin |
07/01/2018 | 100 | Gross Margin |
07/01/2018 | 100 | Gross Margin |
07/01/2018 | 100 | B |
07/01/2018 | 100 | B |
07/01/2018 | 100 | B |
07/01/2018 | 100 | B |
07/01/2018 | 100 | B |
07/01/2018 | 100 | B |
07/01/2018 | 100 | C |
07/01/2018 | 100 | C |
https://1drv.ms/x/s!AqdCRujnTMTHh0HpnhOVJuK3xwn5 .... (excel sharable link)
From this dataset I would like to create a Measure that gives me the Gross Margin Total, which will change by each month, just like the table bellow (in a matrix form). Please note that I've left the calculation before the ~~ to augment the understanding
| June - 2018 | July - 2018 |
Gross Margin | 600/600 ~~ 100% | 300/300 ~~ 100% |
B | 300/600 ~~ 50% | 600/300 ~~ 200% |
C | 200/600 ~~ 30% | 200/300 ~~ 66.6% |
I've tried to make this by the following calculation and some variations, which failed.
Measure = VAR CurrMonthYear = FIRSTNOBLANK(TABLE[MonthYear]) RETURN CALCULATE( SUM( TABLE[Value]), FILTER(ALL(TABLE), TABLE[Type] = "Gross Margin" && TABLE[MonthYear] = CurrMonthYear))
Solved! Go to Solution.
Hi @Moya_Novaes ,
You are picking up all the table for your filter so the Dates are also being ignored in the FILTER that is being used.
Try to Redo your measure to:
%DRE = ( SUM ( DRE_CONTABILIDADE[Valor] ) / CALCULATE ( SUM ( DRE_CONTABILIDADE[Valor] ), FILTER ( ALL ( DRE_CONTABILIDADE[Nível1] ), DRE_CONTABILIDADE[Nível1] = "(=) RECEITA OPERACIONAL LÍQUIDA" ) ) ) * 100
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Moya_Novaes ,
Use the following measure to achieve the desired result:
% Gross Margin = SUM ( 'Table'[Value] ) / CALCULATE ( SUM ( 'Table'[Value] ); FILTER ( ALL ( 'Table'[Type] ); 'Table'[Type] = "Gross Margin" ) )
Regards,
MFelix
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsI don't really know why, but my data is quite similar with the one I've created for this post and yet the denominator of the percentile gets the sum of all the database Gross Margin values, not the Gross Margin by the current MonthYear.
Any ideas why? I've been thiking about this even in my dreams 😛
Hi @Moya_Novaes ,
You are picking up all the table for your filter so the Dates are also being ignored in the FILTER that is being used.
Try to Redo your measure to:
%DRE = ( SUM ( DRE_CONTABILIDADE[Valor] ) / CALCULATE ( SUM ( DRE_CONTABILIDADE[Valor] ), FILTER ( ALL ( DRE_CONTABILIDADE[Nível1] ), DRE_CONTABILIDADE[Nível1] = "(=) RECEITA OPERACIONAL LÍQUIDA" ) ) ) * 100
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em Português@MFelixAlthough I've marked as answered it isn't.
I've copied the code you posted and I got an infinity in the denominator on rows that are not "(=) RECEITA OPERACIONAL LÍQUIDA".
Personaly it dosn't make sense, any ideas?
Hi @Moya_Novaes ,
Can you share a sample of the file?
Regards,
MFelix
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsMarch 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
89 | |
84 | |
70 | |
51 |
User | Count |
---|---|
206 | |
143 | |
97 | |
79 | |
68 |