The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Is there a formula that solve this?
When the user select a period e.i 2021 P13 W4 from slicer, the line chart will shown the selected period value with the 7 last periods value
I've watched some videos about it but of all them uses a specific date colum, our period colum is based on Year + Period + Week (1-4)
These are the periods
and line chart
Hi @Anonymous ,
You can refer the following links to achieve it.
Display Last N Months & Selected Month using Single Date Dimension in Power BI
Show previous 6 months of data from single slicer selection
--
-- This calculation item works together with the Previous Date table to show
-- 6 months back from the currently selected date in the Date table.
--
'Previous Period'[Previous Period]."Previous 6 Months" =
VAR NumOfMonths = -6
VAR ReferenceDate = MAX ( 'Date'[Date] )
VAR PreviousDates =
DATESINPERIOD (
'Previous Date'[Date],
ReferenceDate,
NumOfMonths,
MONTH
)
VAR Result =
CALCULATE (
SELECTEDMEASURE (),
REMOVEFILTERS ( 'Date' ),
KEEPFILTERS ( PreviousDates ),
USERELATIONSHIP ( 'Previous Date'[Date], 'Date'[Date] )
)
RETURN Result
Previous Dynamic Period using DAX in Power BI
If the above ones can't help you, please provide some sample data(exclude sensitive data) and your expected result with backend logic and special examples. Thank you.
Best Regards
@Anonymous , if you select a period and want data more than that you need independent period /date table.
Assume you have an independent date/period table and one joined. You need have rank on this period to make it work
Column in both tables
Period Rank = RANKX(all(Period),Period[year period],,ASC,Dense)
TI using joined table
This Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])))
Last Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])-1))
This will not work when select 1 and want to display more
//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Period Rank])
var _min = _max -7
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Period Rank] >=_min && 'Date'[Period Rank] <=_max))
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI