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
Anonymous
Not applicable

Visual filter to separate two different columns with values

Hey guys

I have a dataset that looks something like this:

[Product] , [Customer], [Time - Month], [Sales Month], [Sales YTD].

 

What I want to do is to be able to filter out weather a visual should be showing monthly sales or YTD sales.

Currently, I need two seperate visuals for this, but a slicer would be so much better. 

Right now I seperate the two with measures such as SUM([Sales Month]) and SUM([Sales YTD]). 
But if I could have measure like: SUM([Sales Month]) + SUM([Sales YTD]) on my visual, then next to my visual would be a single select slicer that could determine weather I display Month values or YTD values.

What am I missing here? 
P.S - I always get Month + YTD data from the system, so I am not looking to change the underlying data really. 
I only get monthly data from previous month, so YTD DAX time measures are not really working well for me either. 

Any tips would be appreciated.
Rasmus 

1 ACCEPTED SOLUTION

Hi,

 

According to your sample file, i think it is the same with my original post.

Please try to create a slicer table by Enter Data:

1.PNG

Then try this measure:

Sum of Periodic/YTD =
SWITCH (
    TRUE,
    SELECTEDVALUE ( 'New Slicer Table'[New Slicer Value] ) = "Sum of Periodic", SUM ( 'Rasmus - Table'[Periodic] ),
    SELECTEDVALUE ( 'New Slicer Table'[New Slicer Value] ) = "Sum of YTD", SUM ( 'Rasmus - Table'[YTD] )
)

Choose this measure as a Card visual, [New Slicer Value] as a slicer.

When you select one in slicer, the result shows:

2.PNG3.PNG

Here is the changed pbix file:

pbix 

if i have solved your issue, please mark it as a solution for others to see.

Thanks!

 

Best Regards,

Giotto Zhi

View solution in original post

10 REPLIES 10
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create a sample to test:

120.PNG

Create a slicer table by Enter Data first:

121.PNG

Then try this measure:

Measure = 
SWITCH (
    TRUE,
    SELECTEDVALUE ( 'Slicer Table'[Slicer Value] ) = "_Monthly Sales", CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER (
            'Table',
            'Table'[Year] IN FILTERS ( 'Table'[Year] )
                && 'Table'[Month] IN FILTERS ( 'Table'[Month] )
        )
    ),
    SELECTEDVALUE ( 'Slicer Table'[Slicer Value] ) = "_YTD Sales", CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Year] <= MAX ( 'Table'[Year] ) )
    )
)

Choose [Year],[Month] and this measure as a matrix visual, [Slicer Value] as a slicer.

When you select one value in slicer, the result shows:

123.PNG122.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

 

Anonymous
Not applicable

Hi Giotto and thanks for showing interest in helping me out! 

I guess the reason I can't use your solution is because you only have one data field called sales. I have two data fields, Periodic and YTD. I am happy to keep it that way, but want the slicer to reflect one of the two columns.

I made changes to the sample pbix. to include how my data is set up.
Maybe you can use similar logic to my sample table instead? 

 

Pbix 



1A.jpg

 

1B.jpg

 

Hi,

 

According to your sample file, i think it is the same with my original post.

Please try to create a slicer table by Enter Data:

1.PNG

Then try this measure:

Sum of Periodic/YTD =
SWITCH (
    TRUE,
    SELECTEDVALUE ( 'New Slicer Table'[New Slicer Value] ) = "Sum of Periodic", SUM ( 'Rasmus - Table'[Periodic] ),
    SELECTEDVALUE ( 'New Slicer Table'[New Slicer Value] ) = "Sum of YTD", SUM ( 'Rasmus - Table'[YTD] )
)

Choose this measure as a Card visual, [New Slicer Value] as a slicer.

When you select one in slicer, the result shows:

2.PNG3.PNG

Here is the changed pbix file:

pbix 

if i have solved your issue, please mark it as a solution for others to see.

Thanks!

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Thanks Giotto - You made my day with this solution! Very kind of you.

Anonymous
Not applicable

@amitchandak - Maybe you can also try with the PBIX and screenshots I attached above?

I don't think the thread you posted helps me, but with this file it should be pretty clear 🙂 

amitchandak
Super User
Super User

We can create a column to subtract this month YTD from the previous month YTD. I suggest formula based the month format you have .

 

Assume you have formate like jan-2020

The create a date = "1-"& [Month Year], mark this has date

create new previous month column

Last date = Date(Year([Date]),Month([Date])-1, 1) //Assuming month level data

 

new column


Last month ytd = sumx(filter(table, table[product] = earlier(table[product])
&& table[customer] = earlier(table[customer])
&& table[date] = earlier(table[last date])),table[Sales YTD])

 

 

Anonymous
Not applicable

Hi Amit and thanks for helping me out.

I do not see how your solution is solving the issue though, I already have two columns showing both monthly and YTD data so I already have the values figured out. What I would like is a single click to separate what to visualize.

Anonymous
Not applicable

Surely @amitchandak - I will try my best to show and explain:

Here is the format of my data table. As you see I have two columns with values: Monthly values (Periodic) and YTD values (YTD). 

 

2020-03-24_09-17-23.jpg

 

 

 

I would like to be able to filter if the visual should show SUM([Periodic]) or SUM([YTD]).
Currently I need two different visuals for two different measures - but if I could use one visual, a measure of both and a filter slicer to determine which of Periodic and YTD gets displayed.

More clear? 🙂 

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.