The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Need help in adding the values for two warehouse codes in same column.
Please find the input data
My input data has two columns. Warehouse and Stock.
EX: NSWA is a main warehouse and NSWA-SW is sub warehouse and all other warehouse codes are small branches.
My goal is to sum the stock for all the warehouse codes ending with -SW (sub warehouse NSWA-SW ) and its respective main warehouse (NSWA). My measure should ignore all other warehouse codes.
Please find the output
I could only get the value for the warehouse codes ending with -SW using calculate and filter warehouse code by Right 3 characters.
My Dax Query:
SW Warehouse = Calculate(sum(stock), filter(warehouse, right([warehouse code],3) = "-SW"))
I need the logic how to match the -sw warehouse codes with the respective main branch.
I am using direct query for connection to semantic model cannot use power query.
Hi @BhargavVM ,
Hi @Walter_W2022
In my table I have duplicates. It is giving me error in this line
I am sorry @BhargavVM , I could not figure out if there are duplicates and also cannot create virtual table. there are a lot of limitations
@BhargavVM , Please refer to below attached file, I created a virtual table to lookup the stock of parent warehouses, then sum them up to get total, please let me know if you have any questions.
Result:
Virtual table created:
Model:
Hi @Walter_W2022
Thanks for your response.
In my case, I cannot add a new table to my data. I am using direct query mode connecting to the PowerBi semantic model. (My report does not allow me to create either calculated table or calculated column).
It is tricky to work with measure in this case. If you have any alternate solutions using measure, your help will be much appreciated.
Thanks
User | Count |
---|---|
12 | |
9 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
14 | |
9 | |
7 |