Forum Discussion

Bhargav150's avatar
Bhargav150
Frequent Visitor
2 years ago
Solved

How to create new calculated table and filter it dynamically using measures

Hi I'm trying to create a new table based on existing dataset query1 in power bi, Because there is a duplicate values in the Snap_date column in the query1, But we need to use only Snap_date as filter so, that's why I have written a query like these 

 

First created a date table

 

Date Table = 

CALENDAR (

    Min('query1' [Snap_date], 

    Max('query1' [Snap_date]

)

 

Then created 2 measures in the Date Table

Start Date = Min('Date Table'[Date]

End Date = Max('Date Table'[Date]

 

  • My requirement is to place the Date Table Date column in the between slicer and when I change the slicer these values need to go in to measures, Up to here everything working as expected

 

In the last step I have created a table

 

NewTable =

SUMMARIZE (

    FILTER (

        query1,

        query1[SNAP_DATE] >= [Start Date] &&

        query1[SNAP_DATE] <= [End Date]

    ),

    query1[ID],

    query1[LN],

    query1[AMT],

    query1[CITY]

)

 

When I change the values in the slicer why these date measures are not filtering data according to the slicer

 

Please help!

 

7 Replies

  • some_bih's avatar
    some_bih
    Community Champion

    Hi Bhargav150 without model and details it is hard to spot issue.

    Still, try v2 below

    NewTable v2 =

    VAR __Start_Date = Min('Date Table'[Date]

    VAR __End_Date = Max('Date Table'[Date]

    RETURN


    SUMMARIZE (

    FILTER (

    query1,

    query1[SNAP_DATE] >= __Start_Date &&

    query1[SNAP_DATE] <= __End_Date

    ),

    query1[ID],

    query1[LN],

    query1[AMT],

    query1[CITY]

    )

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Bhargav150 ,

    Based on my testing, please try the following methods:

    1.Create the sample table.

    2.Create the new calculated table.

    NewTable = 
    SUMMARIZE (
    	query1,
        query1[SNAP_DATE],
        query1[ID],
        query1[LN],
        query1[AMT],
        query1[CITY]
    )

    3.Create the new relationship between date table and calculated table.

    4.Change the date range in the slicer visual.

    5.The result is shown below.

     

    Best Regards,

    Wisdom Wu

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

    • Bhargav150's avatar
      Bhargav150
      Frequent Visitor

      Hi Anonymous 

       

      FYI, the SNAPSHOT_DATE column updates daily with yesterday's date, but apart from that, the remaining columns' data is 90 percent similar. If I include SNAPSHOT_DATE in the summary, it will cause many duplicates. That's the problem here.