Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
MiquelDespuig
Frequent Visitor

Fact Table With Multiple Units of Measure

Hello Everyone!

 

I'm just starting to learn data modeling and DAX and I'm going crazy with a measure I want to achieve. I have the Data Model in the screenshot. Where:

  • OrdreCompra-Detall (F4311) is a purchase order line item fact table. Where I have these columns for the calculation:
    • Quantitat Rebuda (Quantity Received)
    • Quantitat Demanada UoM (Quantity Received Unit of Measure)
  • ArticlePlanta (F4102) is my Dimension Product.
  • Article (F4101) is a subset of atributes for Dim Product. Where I have the different Units of Measure of the product.
  • FactorsConversió (F41002) where the conversion factors for the different units of the product are stored.

Data ModelData Model

 

Every Product has a primary UoM which can be units, kg or liters. My goal is to calculate the quantity received in KG for every line as a measure so we can analyze purchases by KG or LITERS not only in currency format.

 

For the measure I guess I'll have to use an Iterator, for example SUMX, over the fact table. See my starting point below:

Quantity Received (KG) =
SUMX(
OrdreCompra-Detall (F4311);
'OrdreCompra-Detall (F4311)'[Quantity Received] * CONVERSION FACTOR
)

I have no clue on how to start writing the DAX code to get the CONVERSION FACTOR in my current situation. How can I get the data from the table with the conversion factors in this situation? Is there anything you think I could do to improve the Data Model?

 

Thank everyone for the help! All inputs appreciated!

4 REPLIES 4
Stachu
Community Champion
Community Champion

Can you add sample tables (in format that can be copied to PowerBI) from your model with anonymised data? Like this (just copy and paste into the post window).

Column1 Column2
A 1
B 2.5


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

@Stachu I've filtered the data for one of the articles which has multiple units of measure. Not all articles have them. Hope this helps!

OrdreCompra-Detall (F4311)

Spoiler
_Document_CodiLinia_Adreça_Data Entrega Sol·licitada_Data Creació PO_Data Entrega Promesa_Data Entrega_Item_ArticleQuantitat Demanada UoMQuantitat DemanadaQuantitat RebudaCost UnitariQuantitat Demanada ArticlePest Total LíniaPes Total Línia UoMVolum Total LíniaVolum Total Línia UoM_UnitatNegoci_ArticlePlanta_FKQuantitat Demanada Article UoM
200000333000161841200231200071200231200235087101098UN1414187350350KG14LT10VILFR110VILFR1:5087KG
200008383000161841200851200711200851200845087101098UN16216218740504050KG162LT10VILFR110VILFR1:5087KG
20000218100016184120037120024120037 5087101098UN44018711001100KG44LT10VILFR110VILFR1:5087KG
2000102810001618412011812008312011805087101098UN74018718501850KG74LT10VILFR110VILFR1:5087KG
200002801000161841200371200291200371200365087101098UN444418711001100KG44LT10VILFR110VILFR1:5087KG
200004611000161841200541200431200541200515087101098UN2525187625625KG25LT10VILFR110VILFR1:5087KG
200004961000161841200551200451200551200555087101098UN2828187700700KG28LT10VILFR110VILFR1:5087KG
200003361000161841200501200341200501200495087101098UN3737187925925KG37LT10VILFR110VILFR1:5087KG
200005871000161841200621200511200621200595087101098UN2828187700700KG28LT10VILFR110VILFR1:5087KG
200006551000161841200651200581200651200645087101098UN565618714001400KG56LT10VILFR110VILFR1:5087KG
200007601000161841200781200651200781200775087101098UN2525187625625KG25LT10VILFR110VILFR1:5087KG

ArticlePlanta (F4102)

Spoiler
_Item_UnitatNegoci_Marca_Eco/Conv_Tipología_Subclassificació_Alérgenos_IntrastatBranch/PlantEco/ConvencionalTipologíaSubclasificaciónAlérgeno_ArticlePlanta_PK
508710VILFR1 CONMPIBR  FRIGORIFICCONVENCIONALMATERIA PRIMERAINGREDIENT.10VILFR1:5087

Article (F4101)

Spoiler
_Item_Article_Marca_Marca/PropiedadUoM PrimaryUoM SecondaryUoM PurchasingUoM WeightUoM VolumeDescripció Article
5087101098  KGUNUNKGLTGLUCOZYME BIDÓ 25 KG

 FactorsConversió (F41002)

Spoiler
_Item_FromUoM_ToUoMConversion FactorTo UoMFrom UoM
5087KGLT0,04LitersKilograms
5087KGUN0,04UnitsKilograms

 

Was there a solution provided for this? I am working with a similar table with From Units & To Unit conversions at an individaul item level. 

@shawnsoris a DAX solution was never provided for this situation, and I'm definitely not enough proficient in DAX to provide one.

 

What I ended up doing:

  • It's ok to have a column with differents units of measure in a fact table but be very careful with this column as its not additive (try to have additive columns as much as you can).
  • In wanted to provide a lot of functionality by givind the user the ability to select different units of measure dynamically. BUT! Talking to the end user they wanted to analize in 2 specific units of measure. Pallets and Liters.
  • So, I joined the conversion factor table to the fact table in Power Query by item and UoM for the transaction and added a Liters column and a Pallets column. Once you have a column entirely in one unit of measure then it becomes additive. Your DAX now is very simple: 

 

SUM( 'Table Name'[Column In Specific UoM] )​

 

  • It depends a lot in your data source but try to be aware of: What happens if the transaction does not have a conversion factor? It should be zero, or you want to place a really big number to have a flag that something went wrong, or there's a default value that should be used.

In my opinion the good thing about this solution is that all one-to-many relationships end up pointing in the direction you want them to and you can skip loading the conversion factor table to your model so it's simpler and easier to use.

If I wanted to calculate dynamically the conversion factors now I would go with maybe a virtual relationship or propagating a filter. These 3 awesome articles from The Italians helped me a lot:

Hope this helps, and if you go the DAX route please share your solution! 😜 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.