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
nmeliasp
Regular Visitor

Multiple Date Column slicer

Hello i am relatively new to PowerBI and need some help

 

I have 3 columns that have dates in them simillar to example below. How can i create One slicer to see every completion in October for example? 

 

X completionY Completion Z Completion
10/1/201811/1/201810/15/2018
1 ACCEPTED SOLUTION

@nmeliasp,

 

You may try using CALCULATE Function to change the context.

https://www.sqlbi.com/articles/filter-arguments-in-calculate/

Community Support Team _ Sam Zha
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

14 REPLIES 14
AlB
Super User
Super User

Hi @nmeliasp

 

You could create a Calendar table with a relationship for example to Table[X Completion].

The you create a simple measure:

[Completions]= COUNT(Table[X Completion])

 

Use a slicer with the month column from Calendar and  select the month you want.   

i would like to specify a month for example October and see completions from X Completion Column and Z Completion Column. Not sure if your solution willl work for that.

Let's see if I understand what you're after. In the table you've depicted, what would be the result then for October, 2? OR do you want separate results for each column X, Y, Z?

i would like to seperate the results for each column

Ok,  you can have one measure for each column following what I described earlier although that would imply having

a relationship between Calendar and your data table for each column, which is cumbersome if the number of columns is high. Additionally, you would need to use USERELATIONSHIP to activate the relationships as in:

 

[Completions X]= CALCULATE(COUNT(Table[X Completion]),

                                             USERELATIONSHIP(Table[X Completion],Calendar[Date]))    

 

In any case, the way your table is organised is not the most convenient. Probably best to rearrange it in a more "processable" way so that you have something like:

 

Date                 Type_of_Completion 

10/01/18                   X

11/01/18                   Y

10/15/18                   Z

 

You can do this easily in the query editor with the Pivot and Unpivot operations. 

With this table you would create a sole relationship between Calendar[Date] and Table[Date] and then you can use the measure

 

COUNT(Table[Type_of_Completion ])

 

with [Type_of_Completion] in rows of your matrix and the slicer for the month. Make sense?

 

 

 

 

This is a great start thank you. Now my next task is being able to measure the differences between these columns. is there a way to have an unpivoted version and a pivoted column? I find measuring the difference between te different completion columns is easier when each completion type is a column unless i'm missing something

@nmeliasp

Well, all the info for calculating the differences is in what we did before. I don't know how you want to show it.  

You could, if the number of types of completions is low, have hard-coded measures like:

 

[Compl_X]= CALCULATE(COUNT(Table[Type_of_Completion ]);Table[Type_of_Completion="X")   

[Compl_Y]=CALCULATE(COUNT(Table[Type_of_Completion ]);Table[Type_of_Completion="Y")

 

and then create other measures simply with the difference.

 

Another option, although probably overly complicated for what you need, would be to add an additional column to the table shown earlier that's just a copy of Type_of_Completion:

 

Date                 Type_of_Completion      Type_of_Completion_Filter

10/01/18                   X                                          X

11/01/18                   Y                                          Y

10/15/18                   Z                                          Z    

 

You can then have have Type_of_Completion in rows of the matrix, Type_of_Completion_Filter in a slicer and by selecting one of X, Y or Z on the slicer you choose which one you ant to subtract from those in the rows. This would require a measure like this

 

Measure_Diff =
CALCULATE (
    COUNT ( Table[Type_of_Completion] ),
    ALL ( Table[Type_of_Completion_Filter] )
)
    - CALCULATE (
        COUNT ( Table[Type_of_Completion_Filter] ),
        ALL ( Table[Type_of_Completion] )
    )

   

Hi,

 

Share some data and also show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I need to calculate the number of days between the different completion types

 

Ffor example:

 

Z Completion - X Completion

10/15/2018 - 10/1/2018

 

goal is to measure cycle times for these three completion types

 

You need to be less ambiguous describing what you want. I do not understand it.

A sample of the data model would also be helpful.

Here is an example of what i am trying to calculate. This would be a DATEDIFF between Completion X and Completion Y, however these columns were melted into an attribute->value columns when i did an unpivot action on them. Hope this helps...

 

Completion XCompletion YCompletion ZCycle Time X-YCycle Time Y-Z
10/1/201811/1/201812/1/20183130
10/2/201811/12/201812/2/20184120
10/3/201811/3/201812/3/20183130
10/4/201811/14/201812/4/20184120
10/5/201811/5/201812/4/20183129
10/6/201811/16/201812/4/20184118
10/7/201811/7/201812/4/20183127

So you already have it. A DATEDIFF and that is it. What is the problem?

 

my problem now is i did an unpivot action and now my columns look like this

 

Completion TypeCompletion Date
Completion X10/1/2018
Completion Y11/1/2018
Completion Z12/1/2018

 

I am trying to pivot these columns back but having trouble retainig the values. Is there a different way to calcuate the DATEDIFFs between these completion types withouth having to pivot the columns back?

@nmeliasp,

 

You may try using CALCULATE Function to change the context.

https://www.sqlbi.com/articles/filter-arguments-in-calculate/

Community Support Team _ Sam Zha
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.