Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I am trying to build a waterfall chart with calendar wek on X axis and number of items on Y axis. I wan to visualize number of open iems and closed items in each week. Sample data:
Expected result:
To calculate the number of currently active pharmacies in a given year (based on the slicer), we are going to create two measures that will denote whether or not the pharmacy was opened prior or during to the selected year(s) (by giving a value of 1) and/or closed prior to or during the selected years (giving a value of -1)
IsOpen = IF ( CALCULATE ( MINX ( pharmacy, pharmacy[openDate] ) ) <= LASTDATE ( 'Date'[Date] ), 1, 0 )
IsClosed = VAR minDate = CALCULATE ( MINX ( pharmacy, pharmacy[closedate] ) ) RETURN IF ( AND ( minDate <= LASTDATE ( 'Date'[Date] ), NOT ( ISBLANK ( minDate ) ) ), -1, 0 )
Finally, the number of current active pharmacies is simply the sum of IsOpen and IsClosed
Pharmacy Active = CALCULATE ( SUMX ( pharmacy, [IsOpen] ) + SUMX ( pharmacy, [IsClosed] ) )
And the number of active pharmacies in the year prior to the minimum selected year
Pharmacy Active LY = VAR minSelYear = YEAR ( CALCULATE ( MIN ( 'Date'[Date] ), ALLSELECTED ( 'Date'[Year] ) ) ) VAR PAMinSel = CALCULATE ( [Pharmacy Active], 'Date'[Year] = minSelYear - 1 ) RETURN IF ( ISBLANK ( PAMinSel ), 0, PAMinSel )
This is how I want the waterfall chart to look like
Hello,
You can use d3 and combine waterfall chart with the line, using different layers.
For waterfall I found this example that looks exactly what you look for.
Kind Regards,
Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
pbicvsupport@microsoft.com
Hello,
Thanks for sharing. But it is difficult to interpret and understand the code. Do you suggest any other simpler way to understand it?