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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
KasireddyVeen
Frequent Visitor

Waterfall chart: Current quarter - Previous Quarter logic is not working

Hi,

 

I'm trying to create a waterfall chart that shows a Quarter in X-axis and the raise and fall of usage in the Yaxis,

first quarter should show the actual value of that quarter and from the next quarter onwards it should show the current - previous


Table I'm using = Sample

DateUsageSite IdSite NameY-QYQRank
22-Dec-228.6881A2022-Q41
20-Jan-238.0581A2023-Q12
20-Apr-235.5081A2023-Q23
20-Jul-23 81A2023-Q34
20-Oct-23 81A2023-Q45
22-Dec-2210.1982B2022-Q41
20-Jan-239.2682B2023-Q12
20-Apr-235.8382B2023-Q23
20-Jul-23 82B2023-Q34
20-Oct-23 82B2023-Q45
22-Dec-228.9483C2022-Q41
20-Jan-238.8983C2023-Q12
20-Apr-235.2783C2023-Q23
20-Jul-23 83C2023-Q34
20-Oct-23 83C2023-Q45

KasireddyVeen_0-1691310469535.png

 

The Dax measure which I'm using is working fine when I choose all site names, but it is not working fine when I choose a particular site (Ex: A) form the slicer.

Measure I'm currently using

Measure =
 VAR __Current = sum('Sample'[Usage])
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(ALL('Sample'),[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result

 

Working fine when I choose all Site Names

KasireddyVeen_0-1691308663765.png  

When I select Only one site name for example 'A', It is giving wrong output as shown below.

KasireddyVeen_1-1691309075137.png

Expected Result

When I select only 'A' The values should be
2022-Q4 = 8.68
2023-Q1 = -0.63  ----> (8.05-8.68)
2023-Q2 = -2.55  ----> (5.50-8.05)


Can some one please help me on this. Thanks in Advnse.

 

1 ACCEPTED SOLUTION
Reddy5833
Helper I
Helper I

Hi Veena,

 

Try with below measure

 

Measure =
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name] = "A") // since we are not using calculate function here, so first we need to filterout the table with required category and keep it in avariable
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result
 
To make it dynamic based on slicer selection (single/multiple/all ) use below measure
Measure 1 =
VAR __Site = VALUES('Sample'[Site Name])
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name]in __Site) 
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result

View solution in original post

3 REPLIES 3
Reddy5833
Helper I
Helper I

Hi @KasireddyVeen,

 

 

Try with below measure

 

Measure =
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name] = "A") // since we are not using calculate function here, so first we need to filterout the table with required category and keep it in avariable
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result
 
To make it dynamic based on slicer selection (single/multiple/all ) use below measure
Measure 1 =
VAR __Site = VALUES('Sample'[Site Name])
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name]in __Site) 
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result
Reddy5833
Helper I
Helper I

Hi Veena,

 

Try with below measure

 

Measure =
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name] = "A") // since we are not using calculate function here, so first we need to filterout the table with required category and keep it in avariable
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result
 
To make it dynamic based on slicer selection (single/multiple/all ) use below measure
Measure 1 =
VAR __Site = VALUES('Sample'[Site Name])
 VAR __Current = sum('Sample'[Usage])
VAR __Table = FILTER(ALLSELECTED('Sample'),'Sample'[Site Name]in __Site) 
  VAR __CurrentQR = MAX('Sample'[YQRank])
  VAR __Previous = SUMX(FILTER(__Table,[YQRank] = __CurrentQR - 1), [Usage])
  VAR __Result = IF(__Current=BLANK(),"0",__Current - __Previous)
RETURN
__Result

Hi,

 

Thanks for the reply, it is working as expected. that was a great help.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors