The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, friends.
I have a table in Power BI with the columns Object, Item, Period, and Value. I have a pivot table visualization where I have rows from Items, columns from Period, and values from Value. I also have a Measure
ShiftedValue =
VAR CurrentPeriod = SELECTEDVALUE('Pro Forma1'[StartPeriod])
VAR ShiftPeriod = CALCULATE(MIN('Pro Forma1'[StartPeriod]), ALL('Pro Forma1')) - SELECTEDVALUE('Period'[StartPeriod], BLANK())
RETURN
CALCULATE(
SUM('Pro Forma1'[Value]),
'Pro Forma1'[StartPeriod] = CurrentPeriod + ShiftPeriod
)
that allows me to have a Period slicer such that if I select a specific period on this slicer, that period becomes the first period for the pivot table. For example, if initially the first period is 2026, and I select 2024 on the slicer, then all values of 2026 become values of 2024, values of 2027 become values of 2025, values of 2028 become values of 2026, and so on.
However, I am facing a challenge.
I need to be able to add another slicer that will allow me to select values from the Object column for which the shift specified in the Period slicer will apply. If an object is not one of the ones selected in the Object slicer, then the shift should not be performed.
Any ideas on how to achieve this?
Thank you in advance!
Give this a try
ShiftedValue =
VAR CurrentPeriod = SELECTEDVALUE('Pro Forma1'[StartPeriod])
VAR ShiftPeriod = CALCULATE(MIN('Pro Forma1'[StartPeriod]), ALL('Pro Forma1')) - SELECTEDVALUE('Period'[StartPeriod], BLANK())
VAR SelectedObjects = VALUES('Pro Forma1'[Object])
RETURN
CALCULATE(
SUM('Pro Forma1'[Value]),
'Pro Forma1'[StartPeriod] = CurrentPeriod + ShiftPeriod,
'Pro Forma1'[Object] IN SelectedObjects
)
Thank you for reply.
Yes, I tried such way, but unfortunately it doesn't work. Such measure will filter only those objects, that are in SelectedObjects and remove from the pivot table those, that are not there. But I need to have all objects in the pivot table, but the shift would to be applied only for those that are in SelectedObjects.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |