Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
can any one help me to write the script i want to get the result below
From Date Table and Data table
the rule is if sum of sales per week >=15 then it's 1, then i will need to sum the week based on period.
i got this by if( sum(sales)>=15,1,0), but i don't know how to sum it again by period
Solved! Go to Solution.
Hi @markcabantog ,
According to your description, here's my solution.
1.The two tables are related with Date column.
2.Create a calculated column in Data table.
WeekNo = RELATED('Date'[WeekNo])
2.Create a measure.
Measure =
VAR _T =
ADDCOLUMNS (
'Data',
"Flag",
IF (
SUMX (
FILTER ( 'Data', 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] ) ),
'Data'[Sales]
) > 15,
1,
0
)
/ COUNTROWS (
FILTER (
'Data',
'Data'[Veg] = EARLIER ( 'Data'[Veg] )
&& 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] )
)
)
)
RETURN
SUMX ( _T, [Flag] )
Get the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @markcabantog ,
According to your description, here's my solution.
1.The two tables are related with Date column.
2.Create a calculated column in Data table.
WeekNo = RELATED('Date'[WeekNo])
2.Create a measure.
Measure =
VAR _T =
ADDCOLUMNS (
'Data',
"Flag",
IF (
SUMX (
FILTER ( 'Data', 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] ) ),
'Data'[Sales]
) > 15,
1,
0
)
/ COUNTROWS (
FILTER (
'Data',
'Data'[Veg] = EARLIER ( 'Data'[Veg] )
&& 'Data'[WeekNo] = EARLIER ( 'Data'[WeekNo] )
)
)
)
RETURN
SUMX ( _T, [Flag] )
Get the correct result:
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @markcabantog ,
You can directly write measure as below:-
Measure = IF(SUM('Table (2)'[sales])>= 15,1,0)
Output:-
Refer a file below:-
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
92 | |
87 | |
84 | |
65 | |
49 |
User | Count |
---|---|
140 | |
114 | |
110 | |
59 | |
59 |