Forum Discussion

JOKA's avatar
JOKA
Advocate I
6 years ago
Solved

SLICER AS A FILTER FOR DATA TABLE

Hi

 

I need help with dax. I have three tables:

- a calendar table

- a data table (fact table)

- a table with ratios

 

The ratios table is as follows: 

DateDate AnalysisRatio
Jan-20Jul-201,01
Feb-20Jul-201,02
Mar-20Jul-201,05
Apr-20Jul-201,07
May-20Jul-201,03
Jun-20Jul-201,02
Jul-20Jul-201
Jan-20Aug-201,084
Feb-20Aug-201,077
Mar-20Aug-201,07
Apr-20Aug-201,06
May-20Aug-201,05
Jun-20Aug-201,03
Jul-20Aug-201,02
Aug-20Aug-201

 

For each month of Date Analysis, I have a ratio associated to each previous month.

In the dashboard I have a Date slicer (calendar field) and measures that need to be adjusted by the correspondent ratio for each month depending on the selected month in the slicer.

For ex.

- If the user selects July/20 in the slicer, then the measures need to be adjusted: january by  1,01, february by 1,02 ...

- If the user selects August/20 in the slicer, then te measures need to be adjusted: january by 1,084, february by 1,077 ...

 

Do you have any idea hoy can I solve this?

 

I would really appreciate your help.

  • Hi JOKA ,

     

    We can create a measure to meet your requirement.

    1. Create the relationships like following screenshot.

     

     

    2. Then we can create a measure like this,

     

    Indicator Total correct = 
    IF (
        HASONEFILTER ( 'Fact Table'[Date] ) || HASONEFILTER ( 'Table'[Date] ),
        SUM ( 'Fact Table'[Metric] ) * SUM ( 'Table'[Ratio] ),
        SUMX (
            SUMMARIZE (
                'Fact Table',
                'Fact Table'[Date],
                'Fact Table'[Metric],
                "product", 'Fact Table'[Metric] * CALCULATE(SUM('Table'[Ratio]))
            ),
            [product]
        )
    )

     

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    BTW, pbix as attached.

4 Replies

    • JOKA's avatar
      JOKA
      Advocate I

      Thank you for your response! I appreciate it.

      Let me give you an example to explain a bit more the problem:

       

      These are the tables I have

       

       

      In the dashboard I have a slicer that uses the field Date in Calendar Table. If I select August in the slicer, I want to see this:

       
      DateIndicator
      Jan-201626
      Feb-201292,4
      Mar-201391
      Apr-20954
      May-201050
      Jun-20916,7
      Jul-201224
      Aug-201600

       

      the formula = Metric x Ratio

      where Date Analysis = Aug-20

       

      I´m attaching an excel file with the example here:

      https://drive.google.com/file/d/1jgJvsV-QVb42bl3VIi_aFXUjQj-Jk_2u/view?usp=sharing

      • v-zhenbw-msft's avatar
        v-zhenbw-msft
        Community Support

        Hi JOKA ,

         

        We can create a measure to meet your requirement.

        1. Create the relationships like following screenshot.

         

         

        2. Then we can create a measure like this,

         

        Indicator Total correct = 
        IF (
            HASONEFILTER ( 'Fact Table'[Date] ) || HASONEFILTER ( 'Table'[Date] ),
            SUM ( 'Fact Table'[Metric] ) * SUM ( 'Table'[Ratio] ),
            SUMX (
                SUMMARIZE (
                    'Fact Table',
                    'Fact Table'[Date],
                    'Fact Table'[Metric],
                    "product", 'Fact Table'[Metric] * CALCULATE(SUM('Table'[Ratio]))
                ),
                [product]
            )
        )

         

         

         

        If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

         

        Best regards,

         

        Community Support Team _ zhenbw

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

         

        BTW, pbix as attached.

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Community Support

    Hi JOKA ,

     

    How about the result after you follow the suggestions mentioned in my original post?

    Could you please provide more details or expected result about it If it doesn't meet your requirement?

    If you've fixed the issue on your own please kindly share your solution. If the above posts help, please kindly mark it as a solution to help others find it more quickly.

     

    Best regards,

     

    Community Support Team _ zhenbw

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.