Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

undefined

Hi we are migrating Tableau to power bi here i am facing one issue while migrating

 

the screen short is from tableau  i need to implement same in power bi
Years, Quarters, months, weeks ,days, Hours, Minutes
for all this we have sub filters like previous year, last years .... so on for all 
can any one help how can we implement this in power bi

  • Step 1: Create a Disconnected Table for Time Units

    You’ll need a slicer like:

    Time Granularity

    Years

    Quarters

    Months

    Weeks

    Days

    Hours

    Minutes

    Create a table like this (either manually or via Power Query):TimeGranularity = DATATABLE(

        "Granularity", STRING,

        {

            {"Years"},

            {"Quarters"},

            {"Months"},

            {"Weeks"},

            {"Days"},

            {"Hours"},

            {"Minutes"}

        }

    )

     

    Step 2: Create Another Table for Relative Selection

    RelativeOption

    Previous

     

     

     

    RelativeSelection = DATATABLE(

        "Selection", STRING,

        {

            {"Previous"},

            {"This"},

            {"Next"},

            {"To Date"}

        }

    )

     

    Step 3: Create Numeric Input Table for “Last/Next N”

    This table lets users choose N = 1 to 10 (or more):

    NTable = GENERATESERIES(1, 10, 1)

     

    Step 4: Use These as Disconnected Slicers

    Put TimeGranularity, RelativeSelection, and NTable as slicers on your report. They will drive logic in your DAX, not directly filter your date table.

     

    Step 5: Create a Measure or Calculated Table to Filter Dates Based on Selection

    You need a DAX measure that uses selected values from these slicers to compute a dynamic date range:

    SelectedGranularity = SELECTEDVALUE(TimeGranularity[Granularity])

    SelectedOption = SELECTEDVALUE(RelativeSelection[Selection])

    SelectedN = SELECTEDVALUE(NTable[Value])

    TodayDate = TODAY()

     

     

    Then, based on combinations like

    SWITCH(TRUE(),

        SelectedGranularity = "Months" && SelectedOption = "Previous",

            TodayDate >= EOMONTH(TodayDate, -SelectedN) + 1

            && TodayDate <= EOMONTH(TodayDate, -1),

           

        SelectedGranularity = "Months" && SelectedOption = "This",

            TodayDate >= DATE(YEAR(TodayDate), MONTH(TodayDate), 1)

            && TodayDate <= EOMONTH(TodayDate, 0),

     

        -- Add similar logic for Quarters, Weeks, Years, etc.

    )

     

     

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

4 Replies

  • Step 1: Create a Disconnected Table for Time Units

    You’ll need a slicer like:

    Time Granularity

    Years

    Quarters

    Months

    Weeks

    Days

    Hours

    Minutes

    Create a table like this (either manually or via Power Query):TimeGranularity = DATATABLE(

        "Granularity", STRING,

        {

            {"Years"},

            {"Quarters"},

            {"Months"},

            {"Weeks"},

            {"Days"},

            {"Hours"},

            {"Minutes"}

        }

    )

     

    Step 2: Create Another Table for Relative Selection

    RelativeOption

    Previous

     

     

     

    RelativeSelection = DATATABLE(

        "Selection", STRING,

        {

            {"Previous"},

            {"This"},

            {"Next"},

            {"To Date"}

        }

    )

     

    Step 3: Create Numeric Input Table for “Last/Next N”

    This table lets users choose N = 1 to 10 (or more):

    NTable = GENERATESERIES(1, 10, 1)

     

    Step 4: Use These as Disconnected Slicers

    Put TimeGranularity, RelativeSelection, and NTable as slicers on your report. They will drive logic in your DAX, not directly filter your date table.

     

    Step 5: Create a Measure or Calculated Table to Filter Dates Based on Selection

    You need a DAX measure that uses selected values from these slicers to compute a dynamic date range:

    SelectedGranularity = SELECTEDVALUE(TimeGranularity[Granularity])

    SelectedOption = SELECTEDVALUE(RelativeSelection[Selection])

    SelectedN = SELECTEDVALUE(NTable[Value])

    TodayDate = TODAY()

     

     

    Then, based on combinations like

    SWITCH(TRUE(),

        SelectedGranularity = "Months" && SelectedOption = "Previous",

            TodayDate >= EOMONTH(TodayDate, -SelectedN) + 1

            && TodayDate <= EOMONTH(TodayDate, -1),

           

        SelectedGranularity = "Months" && SelectedOption = "This",

            TodayDate >= DATE(YEAR(TodayDate), MONTH(TodayDate), 1)

            && TodayDate <= EOMONTH(TodayDate, 0),

     

        -- Add similar logic for Quarters, Weeks, Years, etc.

    )

     

     

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Thank you for reaching out to Microsoft Fabric Community Forum.

    pankajnamekar25 Thank you for your quick response.

     

    We would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.

     

    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

     

    Please don't forget to give a "Kudos " – I’d truly appreciate it!

     

    Regards,

    B Manikanteswara Reddy

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous ,

       

      As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?

      If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

       

      Please don't forget to give a "Kudos " – I’d truly appreciate it!

       

      Regards,

      B Manikanteswara Reddy

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Thank you for reaching out to Microsoft Fabric Community Forum.

        As we haven’t heard back from you, we will go ahead and close this ticket for now.

        If you need any further assistance, please don’t hesitate to raise a new ticket, we’re always happy to help.

        Our sincere apologies if there was any inconvenience caused.

         

        Regards,

        B Manikanteswara Reddy