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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bizbi
Advocate I
Advocate I

How to get data for 2 columns using different slicers for each column in a table?

Table/Output needed:

image.PNG

 

There is a single column for Category in the dataset. Similarly, there is a single column for Month. The need is to use two slicers (one for base month and the other comparison) to get two columns and then Trend=(Base Month Data-Comparison Month Data). Data for both months is coming from a single 'Value' column in the dataset.

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @bizbi,

 

Suppose the data table is called 'Table1'. First, you need two extra tables that are unrelated to 'Table1', to provide the list of Months.

Table for slicer1 = VALUES(Table1[Month])
Table for slicer2 = VALUES(Table1[Month])

1.PNG

 

Then, create below measures. Now that you want two slicers, you should drag month columns from two separate tables ('Table for slicer1' and 'Table for slicer2') into two slicers.

Slicer1 selection = LASTNONBLANK('Table for slicer1'[Month],1)
Slicer2 selection = LASTNONBLANK('Table for slicer2'[Month],1)

Base Month data = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Month]=[Slicer1 selection]))
Comparison Month data = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Month]=[Slicer2 selection]))

Trend = [Base Month data]-[Comparison Month data] 

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @bizbi,

 

Suppose the data table is called 'Table1'. First, you need two extra tables that are unrelated to 'Table1', to provide the list of Months.

Table for slicer1 = VALUES(Table1[Month])
Table for slicer2 = VALUES(Table1[Month])

1.PNG

 

Then, create below measures. Now that you want two slicers, you should drag month columns from two separate tables ('Table for slicer1' and 'Table for slicer2') into two slicers.

Slicer1 selection = LASTNONBLANK('Table for slicer1'[Month],1)
Slicer2 selection = LASTNONBLANK('Table for slicer2'[Month],1)

Base Month data = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Month]=[Slicer1 selection]))
Comparison Month data = CALCULATE(SUM(Table1[Value]),FILTER(Table1,Table1[Month]=[Slicer2 selection]))

Trend = [Base Month data]-[Comparison Month data] 

2.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.