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.
Please, I need help.
My raw data contains business days with a single value.
But I need to repeat the latest valid value into weekends and holidays.
Below, Z is what I have, ZZ is what I need. See that the latest value from Friday is copied into Saturday and Sunday.
If there is a holiday midweek, it also needs to copy the latest value.
I cannot use query editor (language M), I need to use DAX.
I am having trouble with some commands such as LASTNONBLANK, EARLIEST, EARLIER.
How should I fix this?
Solved! Go to Solution.
Hello @Anonymous
Here is the solution as a calc colum, please let me know if this works:
ZZ = VAR WeekDays = WEEKDAY ( Table1[Date] ) VAR Logic = IF ( WeekDays IN { 7, 1 }, MAXX ( FILTER ( Table1, Table1[Date] < EARLIER ( Table1[Date] ) ), Table1[Z] ) ) RETURN IF ( WEEKDAY ( Table1[Date] ) IN { 7, 1 }, Logic, Table1[Z] )
Hi @Anonymous,
Have you resolved your issue? If you have, welcome to share your solution or mark the right reply as answer. More people will benefit from here.
Best Regards,
Angelia
Sorry for my delay. They put me in another project and I couldn´t test it.
Thanks for the solutions, but they do not work properly.
Solution suggested by @nickchobotar only checks values on weekends. If there is a holiday between monday-friday, the data still remains blank.
Solution suggested by @parry2k it did not work the second script. It says that a single value was expected, but a whole table was provided. (free error translation from pt-br)
zz = if (Table2[z] = BLANK(), LOOKUPVALUE(Table2[z], Table2[index], Table2[index]-1), Table2[z])
@DAN seems like in my rank function somewhere we are getting same value for rank calclated column when there is value in z column. Can you check if that is the case? I worked on sample data your provided and may be i'm missing something.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@parry2k, I am testing on this base. I am simulating extra holiday days.
your first calculated column works as the result below (index).
what is your test base? please show your results.
@Anonymous let me use this as data and test, my first test was based on data you provided in original post.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous
I realized that this can be done using power query, go to query editor, right click on "z" column in your table, choose Fill -> Down, it will fill null values from previous value.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Yes, I know it can be done using power query (M language). But I need to do it using DAX.
ok, give this a try, add new column
index = Rankx(Filter(Table2, Table2[z] <> BLANK()),Table2[Date],,ASC,Skip) - IF(Table2[z]=BLANK(), 1,0)
add new measure zz
zz = CALCULATE(MIN(Table2[z]),filter(ALLSELECTED(Table2), Table2[index]=min(Table2[Index])))
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
why create measure? I need calculated column.
anyway, I created the measure and put it under a table object: it returns exactly the same value from index column.
it is going to be measure and not sure why you are getting the same value as index.
here is screen shot from your sample data and the result.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
my mistake. I was using your first entry for index column. now I updated it and now I get the same data as you.
but still, I need it as a calculated column, not a measure.
any reason why measure will not work? What is the reason that you need column?
Although that can be achieved by adding a new calculated table.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
My true scenario is: I have values and repeated dates in one table. I have currency exchange values in another table with distinct dates.
When I multiply the values between both tables, I need to use columns. If I use measure (I tested now), the measure returns 1 for all rows.
Fill Down option inside Query Editor is the best solution so far, but I want to make it work using DAX.
i guess these both detail table is linked to your other unique date table on date which has exchange rate
so you are looking something like this to add in detail table,
x = zz multiply by exchange rate
correct?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
yes. both tables are conected via date filed.
but my currency table does not contain exchange rate on holidays and weekends, and this is why I need to repeat the last valid value.
I need something like this:
table1[usd] = table1[other_currency] * table2[exchange_rate]
Hello @Anonymous
Here is the solution as a calc colum, please let me know if this works:
ZZ = VAR WeekDays = WEEKDAY ( Table1[Date] ) VAR Logic = IF ( WeekDays IN { 7, 1 }, MAXX ( FILTER ( Table1, Table1[Date] < EARLIER ( Table1[Date] ) ), Table1[Z] ) ) RETURN IF ( WEEKDAY ( Table1[Date] ) IN { 7, 1 }, Logic, Table1[Z] )
Please give a try to following:
add index column
index = Rankx(Filter(Table2, Table2[z] <> BLANK()),Table2[Date],,ASC, Dense)
add zz column (result you are looking for)
zz = if (Table2[z] = BLANK(), LOOKUPVALUE(Table2[z], Table2[index], Table2[index]-1), Table2[z])
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
97 | |
81 | |
77 | |
66 |
User | Count |
---|---|
126 | |
105 | |
103 | |
81 | |
72 |