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
eitanl
Helper II
Helper II

question about Measure

Hi, 

i have encounter a problem i will appreciate your thoughts on

 

made an example to simulate:

 

The DB is looks like that 

 

Date

Item

Current Status Code

Last Month Status Code

Chg Code

Val

31/05/2017

Pen

S

M

SM

1490

30/06/2017

Pen

A

D

AD

1580

 

i want to create a Table in power BI the Shows:

 

Date

30/06/2017

 

 

 

 

Chg Code

 Val

Measure: Last Month Val

AD

1580

1490

 

i.e i am trying to create a measure that will show my the value of  Last Month  in the table of Chg Codes

the problem is i cant go back to DB with the Chg Code because it is not the same 

 

i have used a measure like Calculate(sum(Val),PREVIOUSMONTH(dates(date))  which works perfectly if the table has an item in the rows.  [ in guessi am looking for a formula that will take all items that have AD in their Chg Code for June 2017 and will create a virtual table for those items in the last month, and then sums their value without checking their Chg Code again)

 

any thoughts about how to perceive the result?

 

[ Just for an overview, i want to gather the past info of all items that has their code change between this month to the previous month from A to D)

 

hope i presented my problem clearly

thanks

 

1 ACCEPTED SOLUTION

Hi @eitanl,

 

>>my DB is around 2-3 million rows and i need around 10 of these

If you just want to get a summary records of each items, I'd like to suggest you use summarize function to group them and got the last val.

 

>>do you recommend to use LOOKUPVALUE with big DB?

As you mentioned , if you use measure to calculate through each records, it will spend the lots of system resources.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @eitanl,

 

As smoupre said, you can try to use other columns to group you records, then filter on current group and last date to find out the suitable records.

 

Calculate column:

LastMonth = LOOKUPVALUE([Val],[Item],[Item],[Date],DATE([Date].[Year],[Date].[MonthNo],1)-1)

2.PNG

 

Measure:

LastMonth 2 = 
var current_item=LASTNONBLANK(Sheet3[Item],[Item])
var current_date=MAX(Sheet3[Date])
return
LOOKUPVALUE(Sheet3[Val],Sheet3[Item],current_item,Sheet3[Date],DATE(YEAR(current_date),MONTH(current_date),1)-1)

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks,

i was trying that but i was afraid it takes a lot of computing resources and the report will work slow.

my DB is around 2-3 million rows and i need around 10 of these

do you recommend to use LOOKUPVALUE with big DB?

 

 

Hi @eitanl,

 

>>my DB is around 2-3 million rows and i need around 10 of these

If you just want to get a summary records of each items, I'd like to suggest you use summarize function to group them and got the last val.

 

>>do you recommend to use LOOKUPVALUE with big DB?

As you mentioned , if you use measure to calculate through each records, it will spend the lots of system resources.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

thanks

 

Greg_Deckler
Super User
Super User

Perhaps add an ALLEXCEPT([Item]) to your filter clause? In theory that would eliminate the Chg Code filter context in your table visualization?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.