Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I need to find out if it's possible to solve following case.
In the Fact table there are STOCKS na SALES data aggregated to Date.
User can select/filter data by Year & Month, Year & Week, Year & Quater & Month.
Last (smalest) element defines INTERVAL od data agregation.
Result should show data for selected/filtered period of time, agregated by INTERVAL.
STOCKS in the result must be data for the End Date of the INTERVAL.
In other words STOCK data should be selectively exluded (or marked as excluded) based on curent filter context.
Solved! Go to Solution.
Hi @ggyczew ,
Here are the steps you can follow:
1. Use Enter data to create a Table as a slicer.
2. Create measure.
Year & Month =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&MONTH('Table'[Date])=MONTH(MAX('Table'[Date]))),
[Date]),1,0)
Year & Week =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&WEEKNUM('Table'[Date],1)=WEEKNUM(MAX('Table'[Date]),1)),
[Date]),1,0)
Year & Quater & Month =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&QUARTER('Table'[Date])=QUARTER(MAX('Table'[Date]))),
[Date]),1,0)
Flag =
var _select=
SELECTEDVALUE('Slicer_Table'[Slicer])
return
SWITCH(
TRUE(),
_select="Year & Month",[Year & Month],
_select="Year & Week",[Year & Week],
_select="Year & Quater & Month",[Year & Quater & Month])
3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @ggyczew ,
Here are the steps you can follow:
1. Use Enter data to create a Table as a slicer.
2. Create measure.
Year & Month =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&MONTH('Table'[Date])=MONTH(MAX('Table'[Date]))),
[Date]),1,0)
Year & Week =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&WEEKNUM('Table'[Date],1)=WEEKNUM(MAX('Table'[Date]),1)),
[Date]),1,0)
Year & Quater & Month =
IF(
MAX('Table'[Date])=
MAXX(FILTER(ALL('Table'),
YEAR('Table'[Date])=YEAR(MAX('Table'[Date]))&&QUARTER('Table'[Date])=QUARTER(MAX('Table'[Date]))),
[Date]),1,0)
Flag =
var _select=
SELECTEDVALUE('Slicer_Table'[Slicer])
return
SWITCH(
TRUE(),
_select="Year & Month",[Year & Month],
_select="Year & Week",[Year & Week],
_select="Year & Quater & Month",[Year & Quater & Month])
3. Place [Flag]in Filters, set is=1, apply filter.
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
There is better solution.
"SalesLastDayOfInterval", CALCULATE([Sales Amount], FILTER(Date, 'Date'[Date] = CALCULATE (MAX('Date'[Date]), ALLSELECTED(Date))
Example
https://dax.do/gPu8nlHs9U1BkR/
I have sum of Sales by smallest Calendar Interval and Sales for the Last Day of ecah Interval
After adding Date to ungroup Month
Example. Current Month 3 weeks (ends on Sunday)
Could you provide the sample data and expected result.
User | Count |
---|---|
82 | |
78 | |
67 | |
46 | |
45 |
User | Count |
---|---|
104 | |
44 | |
39 | |
39 | |
39 |