Forum Discussion
Inventory Availability Coverage
- 6 years ago
Sorry I linked to the wrong file. The file is here:
https://1drv.ms/u/s!Ancq8HFZYL_aiJBRfsmli39RRmqCOA?e=5Uo1n3
There is an Inventory table and a YesNo table.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Fun question! I have created the following calculated table that results in what you want:
Table 2 =
ADDCOLUMNS(DATATABLE("Stock", STRING, {{"Yes"}, {"No"}}), "% Available",
VAR _tmpTable = SUMMARIZE(Inventory, Inventory[Product], "TotalInventory", SUM(Inventory[Quantity]))
VAR _rowsOnStock = COUNTROWS(FILTER(_tmpTable, [TotalInventory] > 0))
VAR _rowsNotOnStock = COUNTROWS(_tmpTable)-_rowsOnStock
VAR _totalProducts = COUNTROWS(_tmpTable)
RETURN
IF([Stock] = "Yes",
DIVIDE(_rowsOnStock, _totalProducts),
DIVIDE(_rowsNotOnStock, _totalProducts)
))What this does is the following. DATATABLE creates a single column table with Yes and No rows. Then I add a column to it called "% Available". I then create a summarytable in memory of the Inventory table. This results in a table of two columns, one with Products and one with the sum of inventory of that product. Then I count the rows where inventory is 0 and where not. Finally, if the current row is "Yes" I divide rowsOnStock by totalProducts. If "No", I divide rowsNotOnStock by totalProducts.
Result is this:
Original valuesAdjusted formatting on the column to represent percentages
Let me know if this suits your needs. If you want it to be dynamic (e.g. a table visual), then we need another aproach.
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
- JarroVGIT6 years agoResident Rockstar
I also created a solution based on measures (and a calculated table with just a Yes No column). PBIX can be found here (ignore other tables, they are for other questions)
https://1drv.ms/u/s!Ancq8HFZYL_aiJA8RNb7RX-OsqnWrg?e=3va5Z1
Kind regards
Djerro123
-------------------------------
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂