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.
Hi,
I am unable to get Count of stores which satisfy condition on last 3 months sales.
I have below dataset Table1:
Country | Month (Real) | Day Date (Real) | Distributor ID | Branch ID | Distributor Branch | Store ID | Store Name | Sales |
INDIA | 2022M12 | 10-12-2022 00:00 | 9676358 | 2034234672 | ABC | V00165 | TMP | 102727.2727 |
INDIA | 2022M12 | 24-12-2022 00:00 | 9676358 | 2034234672 | ABC | V00165 | TMP | 144090.9091 |
INDIA | 2023M02 | 25-02-2023 00:00 | 9676358 | 2034234672 | ABC | V00165 | TMP | 936.3637 |
INDIA | 2023M02 | 11-02-2023 00:00 | 9676358 | 2034234672 | ABC | V00165 | TMP | 2200.0002 |
INDIA | 2022M11 | 12-11-2022 00:00 | 9676358 | 2034234672 | ABC | V00165 | TMP | 11955.4547 |
INDIA | 2022M01 | 10-01-2022 00:00 | 8873432 | 2009835247 | ABC | V00165 | QRS | 94754.9874 |
INDIA | 2022M01 | 24-01-2022 00:00 | 8873432 | 2009835247 | ABC | V00165 | QRS | 1090.9091 |
INDIA | 2023M02 | 25-02-2023 00:00 | 8873432 | 2009835247 | ABC | V00165 | QRS | 936.3637 |
INDIA | 2023M02 | 11-02-2023 00:00 | 8873432 | 2009835247 | ABC | V00165 | QRS | 22700.0002 |
INDIA | 2022M12 | 12-12-2022 00:00 | 8873432 | 2009835247 | ABC | V00165 | QRS | 11545.4547 |
I have to calculate last 3 closed months sales. For e.g., if I select any date in february, it should return sales sum of Jan, Dec, Nov for that store. I created last 3 closed months sales measure which is working fine :
Solved! Go to Solution.
Hi @DikshaJaiswal ,
I modified the measures as follows.
Last 3 Month Sales test =
VAR _sel =
SELECTEDVALUE ( 'Calendar Table'[Date] )
VAR _date1 =
EOMONTH ( _sel, -1 )
VAR _date2 =
EOMONTH ( _sel, -4 ) + 1
VAR _sum =
CALCULATE (
SUM ( Table1[Sales] ),
FILTER (
ALLSELECTED ( Table1 ),
[Store Name] = MAX ( 'Table1'[Store Name] )
&& [Day Date (Real)] <= _date1
&& [Day Date (Real)] >= _date2
)
)
RETURN
_sum
Count =
CALCULATE (
DISTINCTCOUNT ( Table1[Store Name] ),
FILTER (
ALLSELECTED ( Table1 ),
[Last 3 Month Sales test] <= 200000
&& [Last 3 Month Sales test] >= 0
)
)
The dates of the slicer come from the [Calendar Date] table, which is not related to the primary table.
You can download my attachment for more details.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @DikshaJaiswal ,
I modified the measures as follows.
Last 3 Month Sales test =
VAR _sel =
SELECTEDVALUE ( 'Calendar Table'[Date] )
VAR _date1 =
EOMONTH ( _sel, -1 )
VAR _date2 =
EOMONTH ( _sel, -4 ) + 1
VAR _sum =
CALCULATE (
SUM ( Table1[Sales] ),
FILTER (
ALLSELECTED ( Table1 ),
[Store Name] = MAX ( 'Table1'[Store Name] )
&& [Day Date (Real)] <= _date1
&& [Day Date (Real)] >= _date2
)
)
RETURN
_sum
Count =
CALCULATE (
DISTINCTCOUNT ( Table1[Store Name] ),
FILTER (
ALLSELECTED ( Table1 ),
[Last 3 Month Sales test] <= 200000
&& [Last 3 Month Sales test] >= 0
)
)
The dates of the slicer come from the [Calendar Date] table, which is not related to the primary table.
You can download my attachment for more details.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |