Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello
I am trying to sum the results of the measure that in my model is called "Avg vs Last Avg"
My intention is count how many points increase or decrease.
my expected result is get a count like the red numbers on the right.
All my calculations are measures.
Solved! Go to Solution.
Hi, @Lu1sT0rr3s
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Table 2(a calcualted table):
Table 2 =
SUMMARIZE(
'Table',
'Table'[YearMonth],
"Avg vs Last Month Avg",
IF(
SUM('Table'[Average])<=SUM('Table'[Last Month Average]),
0,1
)
)
Calendar(a calculated table):
Calendar =
ADDCOLUMNS(
CALENDARAUTO(),
"YearMonth",
YEAR([Date])*100+MONTH([Date])
)
You may create a measure as below.
Result =
var tab =
ADDCOLUMNS(
SUMMARIZE(
'Table',
'Table'[YearMonth],
"Avg vs Last Month Avg",
IF(
SUM('Table'[Average])<=SUM('Table'[Last Month Average]),
0,1
)
),
"<> max",
CALCULATE(
MAX('Table 2'[YearMonth]),
FILTER(
ALL('Table 2'),
'Table 2'[YearMonth]<EARLIER('Table'[YearMonth])&&
[Avg vs Last Month Avg]<>EARLIER([Avg vs Last Month Avg])
)
),
"= min",
CALCULATE(
MIN('Table 2'[YearMonth]),
FILTER(
ALL('Table 2'),
'Table 2'[YearMonth]<EARLIER('Table'[YearMonth])&&
[Avg vs Last Month Avg]=EARLIER([Avg vs Last Month Avg])
)
)
)
var t =
ADDCOLUMNS(
tab,
"Result",
IF(
[= min]<[<> max],
COUNTROWS(
CALCULATETABLE(
DISTINCT('Calendar'[YearMonth]),
FILTER(
ALL('Calendar'),
[YearMonth]>=[<> max]&&
[YearMonth]<=EARLIER('Table'[YearMonth])
)
)
)-1,
IF(
[= min]>[<> max],
COUNTROWS(
CALCULATETABLE(
DISTINCT('Calendar'[YearMonth]),
FILTER(
ALL('Calendar'),
[YearMonth]>=[= min]&&
[YearMonth]<=EARLIER('Table'[YearMonth])
)
)
),
1
)
)
)
return
SUMX(
t,
[Result]
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Lu1sT0rr3s
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Table 2(a calcualted table):
Table 2 =
SUMMARIZE(
'Table',
'Table'[YearMonth],
"Avg vs Last Month Avg",
IF(
SUM('Table'[Average])<=SUM('Table'[Last Month Average]),
0,1
)
)
Calendar(a calculated table):
Calendar =
ADDCOLUMNS(
CALENDARAUTO(),
"YearMonth",
YEAR([Date])*100+MONTH([Date])
)
You may create a measure as below.
Result =
var tab =
ADDCOLUMNS(
SUMMARIZE(
'Table',
'Table'[YearMonth],
"Avg vs Last Month Avg",
IF(
SUM('Table'[Average])<=SUM('Table'[Last Month Average]),
0,1
)
),
"<> max",
CALCULATE(
MAX('Table 2'[YearMonth]),
FILTER(
ALL('Table 2'),
'Table 2'[YearMonth]<EARLIER('Table'[YearMonth])&&
[Avg vs Last Month Avg]<>EARLIER([Avg vs Last Month Avg])
)
),
"= min",
CALCULATE(
MIN('Table 2'[YearMonth]),
FILTER(
ALL('Table 2'),
'Table 2'[YearMonth]<EARLIER('Table'[YearMonth])&&
[Avg vs Last Month Avg]=EARLIER([Avg vs Last Month Avg])
)
)
)
var t =
ADDCOLUMNS(
tab,
"Result",
IF(
[= min]<[<> max],
COUNTROWS(
CALCULATETABLE(
DISTINCT('Calendar'[YearMonth]),
FILTER(
ALL('Calendar'),
[YearMonth]>=[<> max]&&
[YearMonth]<=EARLIER('Table'[YearMonth])
)
)
)-1,
IF(
[= min]>[<> max],
COUNTROWS(
CALCULATETABLE(
DISTINCT('Calendar'[YearMonth]),
FILTER(
ALL('Calendar'),
[YearMonth]>=[= min]&&
[YearMonth]<=EARLIER('Table'[YearMonth])
)
)
),
1
)
)
)
return
SUMX(
t,
[Result]
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @v-alq-msft
Thanks for take the time to help me out to solve this.
I tryed but it seems that you "Average" and "Last Month Average" are data from a table, but for me are measures, and when I try does not work due does not recognize, in my case, the "average" and "last month Average".
Regards,
LT
@Lu1sT0rr3s can you provide some more detail about what exactly this desired measure is counting? It's not clear at all to me from the numbers you provided.
User | Count |
---|---|
95 | |
86 | |
78 | |
72 | |
67 |
User | Count |
---|---|
110 | |
104 | |
84 | |
65 | |
63 |