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
pradeep467
Helper III
Helper III

How to retreive multiple values from a table by sending more than 1 parameter as input DAX

Hi Experts,

I am facing some issues with lookup in Power Bi..I have my tables as

Week Dim  

                   

Week   Period Quarter  Year  Prior Year Week
2020022020012020012020201902
2020032020012020012020201903

 

Period Dim

Period Quarter  Year  Prior Year Period
2020012020012020201901
2020022020012020201902

 

I have multi-select slicers on my report for year, period,qtr and week

My fact table is at a week granularity

For my Year over year calculations when user selects any period it has to lookup the week dimension using the Prior Year Period  from period Dim and return the list of weeks it has to aggregate.

I tried using lookup finction but it fails when more than 1 value is selected in slicer.

So if a user sleect 2 periods from period slicer, I need to lookup week dim and get 8 weeks for the selected periods..what functions can I use in order to get this functionality

6 REPLIES 6
pradeep467
Helper III
Helper III

At a high level what I am struggling to get through DAX is,

If a user selects 2 periods in the period slicer, I am looking for dax equivalent for below 2 queries

 

prior_year_periods=select prior_year_period from period_d where period_id=selectedvalues(period)

weeks_list=select week from week_d where period in prior_year_period_id

pradeep467_0-1593304651270.png

Any help would be really appeciated.

This would be easier if you had a Date table, and Marked it As Date Table.  You could then use DAX Time Intelligence to make your calculation easier.  Your Date table can have columns for week, period, etc.

 

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks for the pointer Pat, but I am not sure how a Date table wil answer my problem as my fact table is at a week granularity. So I have week numbers stored as foreign keys and I am detrming prior year periods and weeks using week or period dimensions.

A Date table could actually be used and have a column that matches you period column.  In any case, you should add an integer column to your Period table, and a column that has the year in integer form.  That will make DAX expressions easier so you can add/subtract weeks/years more easily.  A column that has a sequence of weeks throughout your whole date range would probably be useful too (for when you are subtracting weeks at the start of the year into the previous year, for example).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


v-easonf-msft
Community Support
Community Support

Hi ,  @pradeep467 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

PBIX/some sample data and expected result would help tremendously.

 

Best Regards,
Community Support Team _ Eason

 

Thanks for replying...so here is my case

my fact table is like

pradeep467_0-1593192217858.png

 

And my report is like

pradeep467_1-1593192250598.png

 

So as mentioned in my initial message, each period has 4 weeks..

so if user select 2 periods from the period slicer (202001,202002) , then we have to look up the Period dimenison to get the perior year periods for these 2 which in this case are 201901 and 201902.

Using these periods we have to look up the week dimenion to see what weeks falls under these 2 periods(201901-201908) and aggregate the Sales for those weeks as last year sales.

 

I used SELECTEDVALUE but it fails when a second value is selected in slicer.

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.