Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Exclude a column from a filter

Hello,

 

I would like to exclude a column from the DATEINPERIOD filter or make sure that this filter only concerns certain columns in a calculation using the CALCULATE function.

 

Durée moyenne par session cumulée au mois =
CALCULATE(SUM('Google analytics'[Number of sessions])/SUM('Google analytics'[Cumulative number of session each week])*SUM('Google analytics'[Average time per session]),
ALL('Google analytics'),
DATESINPERIOD(
'Google analytics'[Date],
FIRSTDATE('Google analytics'[Date]),
-1,
MONTH)

 

I want to exclude [Cumulative number of session each week] from the DATESINPERIOD FILTER or make the filter affect only [Number of sessions] and [Average time per session].

I put an example below.

 

Thank you in advance for your answers.

  • Anonymous In addition to your question, I saw how you used the data column inside the DATESINPERIOD function. This is not how you should do that. Either you have a dim dates you created or you use the autodate time table. 
    For simplicity, let's say you use the autodate time, than your measure is:

     

    DIVIDE(
    	CALCULATE (
    	    SUM ( 'Google analytics'[Number of sessions] )
    	        * SUM ( 'Google analytics'[Average time per session] ),
    	    DATESINPERIOD (
    	        'Google analytics'[Date].[Date],
    	        FIRSTDATE ( 'Google analytics'[Date] ),
    	        -1,
    	        MONTH
    	    )
    	),
    	 SUM ( 'Google analytics'[Cumulative number of session each week] )
    )

     

    Pay attention to the version I used:
    'Google analytics'[Date].[Date]

    Also, you don't need the ALL argument as you play with filters on the date table anyway.


    Showcase Report – Contoso By SpartaBI


          

3 Replies

  • SpartaBI's avatar
    SpartaBI
    Community Champion

    Anonymous In addition to your question, I saw how you used the data column inside the DATESINPERIOD function. This is not how you should do that. Either you have a dim dates you created or you use the autodate time table. 
    For simplicity, let's say you use the autodate time, than your measure is:

     

    DIVIDE(
    	CALCULATE (
    	    SUM ( 'Google analytics'[Number of sessions] )
    	        * SUM ( 'Google analytics'[Average time per session] ),
    	    DATESINPERIOD (
    	        'Google analytics'[Date].[Date],
    	        FIRSTDATE ( 'Google analytics'[Date] ),
    	        -1,
    	        MONTH
    	    )
    	),
    	 SUM ( 'Google analytics'[Cumulative number of session each week] )
    )

     

    Pay attention to the version I used:
    'Google analytics'[Date].[Date]

    Also, you don't need the ALL argument as you play with filters on the date table anyway.


    Showcase Report – Contoso By SpartaBI