Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi all,
I seem to be having trouble creating a variable value for a sort of do while loop.
My formula works fine. But I need '[Object sort]-<number>' to work as a variable. How does this work?
Is this possible in DAX?
RESULT =
IF(
[Object A]=""
SWITCH(
TRUE(),
LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-1)<>"",LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-1),
LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-2)<>"",LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-2),
LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-3)<>"",LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-3),
LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-4)<>"",LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-4),
LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-5)<>"",LOOKUPVALUE(EQUIPMENTS[Object A],[Object sort],[Object sort]-5),
.........
),
BLANK()
)
@enieuwer Here is how to do For and While loops in DAX: For and While Loops in DAX – Greg Deckler
And the videos:
Hi Greg,
Thank you for you swift answer.
Unfortunately your solution is above my knowledge of DAX. I was hoping for an easier solution.
Hi @enieuwer ,
In order to get a better understanding on your requirement and give you a suitable solution, could you please provide some raw data in your table 'EQUIPMENTS' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
78 | |
54 | |
39 | |
35 |
User | Count |
---|---|
102 | |
84 | |
48 | |
48 | |
48 |