Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I'm having a problem with a measure calculations. Hoping for your help.
What I want to do is to calculate difference between Value Delivered and Value Ordered in each month (please find example below). Data I have is in weeks perspective and the measure is tend to display aggregated month values for each week in a chart. Value Ordered is generated at the end of each month and it concerns order value for next month.
Example for week 10 (and for all weeks in month number 3 basically):
Value Ordered is 26
Sum of Value Delivered is 21
The measuer should give the result -5 (21 - 26)
I tried to create date values from week and year in ored to use PREVIOUSMONTH() and EARLIER() but it didn't work. I don't have a clue how to solve this problem. Do you have any advice?
Thanks,
Blazej
Solved! Go to Solution.
Hi @BlazejL,
For your requirement, you could create the formulas below.
Column = VAR a = CALCULATE ( MAX ( 'Table1'[Week] ), FILTER ( ALLEXCEPT ( 'Table1', 'Table1'[ClientID] ), [Year] = EARLIER ( [Year] ) && 'Table1'[Week] < EARLIER ( 'Table1'[Week] ) && [Value Ordered] <> BLANK () ) ) RETURN LOOKUPVALUE ( 'Table1'[Value Ordered], Table1[Week], a, 'Table1'[ClientID], 'Table1'[ClientID] )
measure = CALCULATE ( SUM ( Table1[Value Delivered] ), ALLEXCEPT ( Table1, Table1[ClientID], Table1[Month] ) ) - SUM ( 'Table1'[Column] )
Here is the output.
In addition, you could refer to the attachment.
Best Regards,
Cherry
Hi @BlazejL,
For your requirement, you could create the formulas below.
Column = VAR a = CALCULATE ( MAX ( 'Table1'[Week] ), FILTER ( ALLEXCEPT ( 'Table1', 'Table1'[ClientID] ), [Year] = EARLIER ( [Year] ) && 'Table1'[Week] < EARLIER ( 'Table1'[Week] ) && [Value Ordered] <> BLANK () ) ) RETURN LOOKUPVALUE ( 'Table1'[Value Ordered], Table1[Week], a, 'Table1'[ClientID], 'Table1'[ClientID] )
measure = CALCULATE ( SUM ( Table1[Value Delivered] ), ALLEXCEPT ( Table1, Table1[ClientID], Table1[Month] ) ) - SUM ( 'Table1'[Column] )
Here is the output.
In addition, you could refer to the attachment.
Best Regards,
Cherry
Thank you for help @v-piga-msft. Your solution works well! I tried your solution with additional column named "Country". It also went good. But there is one issue that bothers me. When I changed data source to Excel file from manually inputted file it turned out that ALLECEPT() function in measure doesn't work properly. It removes context of "months" even though this is inputted in ALLEXCEPT () formula.
There is a difference between Value Delivered and Value Ordered in example above but I left just Value Delivered part to simplify the issue.
SumMths3 = CALCULATE(SUM(Sheet1[Value Delivered]), ALLEXCEPT(Sheet1, Sheet1[ClientID ],Sheet1[Country], Sheet1[Month]))
Do you know what is wrong here?
Here is a print screen snippet of the result of formula above:
Please find attached Power BI file with the example.
https://1drv.ms/u/s!AuRFJpKbTTC7hRr3s8ewROXsFnhD
Best Regards,
Blazej
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
118 | |
101 | |
71 | |
61 |