Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
togsoo1
Frequent Visitor

Display the n-1 value in a stacked graphic by the date

 

Hello, I block on a point I would like to have the measure for the sum of the work realized in the month n-1 according to the sectors and that it is changeable thanks to the segment just below which is this one in the time n.

 

for example, there my period of 12 months is 629 for the sector 1, I would like to display the value during the period n-24 months to n-12 months .

That is to say n-(2*x) to n-x

 

so I want to see by doubling my month if I am in decrease or increase compared to my month n-1 chooses.

 

I thank you for all your answers.

 

 

 

cap4.jpg

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Here's one way to do it. Make two measures and put them in a stacked bar chart. This assumes you have a Date table in your model. In the pic, table on left is filtered to Product A to confirm it is working for the two months selected.

 

SelectedPeriod = [Total Qty] //use your measure

 

 

PreviousPeriod =
VAR mindate =
MIN ( 'Date'[Date] )
VAR maxdate =
MAX ( 'Date'[Date] )
VAR monthsselected =
DATEDIFF ( mindate, maxdate, MONTH )
VAR prevmax = mindate - 1
VAR prevmin =
EDATE ( mindate, -1 * ( monthsselected + 1 ) )
RETURN
CALCULATE (
[Total Qty],
ALL ( 'Date' ),
'Date'[Date] >= prevmin
&& 'Date'[Date] <= prevmax
)
 

ppm1_0-1671663958884.png

 

Pat

Microsoft Employee

View solution in original post

2 REPLIES 2
togsoo1
Frequent Visitor

Thank you very well @ppm1 

ppm1
Solution Sage
Solution Sage

Here's one way to do it. Make two measures and put them in a stacked bar chart. This assumes you have a Date table in your model. In the pic, table on left is filtered to Product A to confirm it is working for the two months selected.

 

SelectedPeriod = [Total Qty] //use your measure

 

 

PreviousPeriod =
VAR mindate =
MIN ( 'Date'[Date] )
VAR maxdate =
MAX ( 'Date'[Date] )
VAR monthsselected =
DATEDIFF ( mindate, maxdate, MONTH )
VAR prevmax = mindate - 1
VAR prevmin =
EDATE ( mindate, -1 * ( monthsselected + 1 ) )
RETURN
CALCULATE (
[Total Qty],
ALL ( 'Date' ),
'Date'[Date] >= prevmin
&& 'Date'[Date] <= prevmax
)
 

ppm1_0-1671663958884.png

 

Pat

Microsoft Employee

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.