March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I am responsible for auditing, monitoring and reducing costs of our suppliers. We got fruit and vegs from the market. I have managed to get a daily .csv report of what we buy. So I have combinated through Power Query, and I have a table with the date, item, quantity and price. I have data for a year. So far so good 🙂
The issue is that we do not get always the same "brands" of vegs. For example, I have 11 differents brands for cucumbers and this is true for many other products such as Aubergines, Peppers, Onions etc.
My goal is to have a list of fruits and vegs we buy, with the average price (over the last 6 or 12 months) based on the brands I order the most.
So I created a "mapping" table, that lists all the products and I added a column to input the catergory. For example, in this table I have my 11 different cucumbers brands in one column, and in another column I have all labeled them as "Cucumbers", besides for each row I have the number how many this brand was received, and the frequency compared to the catergory. For example,
Item_Received | Mapping_Category | How_Many_Received | Freq |
Cues Spanish | Cucumbers | 25 | 3.9% |
Cues Neth | Cucumbers | 312 | 49.1% |
Cucumbers Fr | Cucumbers | 98 | 15.4% |
Cues 12/ IRL | Cucumbers | 201 | 31.6% |
I need PQ to sort the fequency in a descending order, then I want to keep all the rows that totalling the at least first 80% of the category. In that example I want PQ to keep only "Cues Neth" and "Cues 12/ IRL" because together the represent more than 80% of the cucumbers I receive.
Obviously, this table contains more fruit and vegs so the M code has to work for all categories
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nVldc6M6Ev0r1DztVs2HJPQBjxgTmwoGFuzJTd29DyRhHdc4dhbbd2b212+DJAxGdpxcUtc1VTpHLan7dLf055+fvDSNgvzLKPOC0SKLc+ur9fXT50+Ewv/QZ0wpE46NbfjX5rBew89NdVjt4dd7fV2Xu09/fW45Jl7knYend5fBSTQOYgVnpIEDkDAbYXKcXf0Y8JkXx/d6eianZ4gjQvHbs6dhfGtF3lgT2EgSOEgQ4rjkEsNiFGSTMA701jm4wSKXc+YIjIfGHx7KarnaDAnGh/3js0Ua86mioTA9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Hbq4aHBBkI07GFMrpfUoEoKd+ry5Q7L59CpXI3DedBP8iJqn7tjjiYojv1sry+Hb5ZF3srhzpsXcIQRvX0PWvTotqty98tMA7TVrG5fQ6xWb3qufI8PK1jmWmdKaQG2Bir+bcCB16vjRpiyuJR11QwOMshn8Q3QRbEftAtySAvCXBDCEsTRdUlSKEAnXqzvtg3SOnG58DT+xwkvpdTDde3z793xVrVFmlUX7kpK40pLF0flLilySyo37wgFXRr1CFi+1IuwWHajqMGRm0WsM9h1to3Mm82Wsy9uJOUh8vIipeHw76QTUddNvvTMLg5yeOQHR3sDvN455WhhqoY0osyFtD13X8nanJvni9mXm4u49RPXux3hxf1XJOnWf1G1J+LS4lxGQgMtwU9nTV/BdFf9ibu0ajivcYp7adcODYnA801MP1rAWH8VZvimFad//dQtB1DDonq7V4wh0T1n/pUJSTz7o7PR3+oPkPV6I78hgKZ76viZ/cxacDTyIzq121XfvTUq96mqRetHo7JufeOIcsCelErj71WhaiuePvTH5ZFZeWbQulQfheMjxdwxHy7lf8sn8p2fDBX8tpKCToLg5K9J7Hz598v5UX/bEbIscmsniRvbrxhf/R1N0bSrQhjLqFYGDi2L50pBzTfj8+T+jFUCEEgLQ2bl3NUszAOrVqpumzKh5AtXEy5O7yZPsfW5aDq1R+KUSiYDO+zZpL+rZXAyEWG6z0zdlSulysouGafjjWOS4XDxVCmzAyd1zGVGoRNGSSX4VXTJYLZh5egG/aPL6Fl+DhF94XfVnovmENc2xk2Fj0KVbzUwv/xpup8BcS0MbZz5lmv5fnr/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, #"Freq_%" = _t, #"Main Seller" = _t, Category = _t, FV = _t]),
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Items", type text}, {"Freq", Int64.Type}, {"Freq_%", Int64.Type}, {"Main Seller", type text}, {"Category", type text}, {"FV", type text}})
in
#"Type modifié"
Solved! Go to Solution.
let
Source = Table.FromRows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uKq0OmpIb9PP1mQx/qNOHB17oARb6+i/4iff9Qucssxe89qduuU2KHb3j8KdYVi+lPZwY3YGCweXkaDa8nKKGMf0J3PjmCETBZek6PDT0V2Ze5q/st/8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, FV = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Freq", Int64.Type}},"fr-FR"),
process = (tbl) =>
let
#"Sorted Rows" = Table.Sort(tbl,{{"Freq", Order.Descending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "First80", each try if List.Sum(List.FirstN(#"Added Index"[Freq],[Index]))/List.Sum(#"Added Index"[Freq])<.8 then true else false otherwise true)
in
#"Added Custom",
#"Grouped Rows" = Table.Group(#"Changed Type", {"FV"}, {{"Rows", each process(_)}}),
#"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Items", "Freq", "First80"}, {"Items", "Freq", "First80"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Rows",{{"Items", type text}, {"Freq", Int64.Type}, {"First80", type logical}})
in
#"Changed Type1"
Hi @Einomi, similar approach as @lbendlin, but with list generate (this one should be faster)
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nVldc6M6Ev0r1DztVs2HJPQBjxgTmwoGFuzJTd29DyRhHdc4dhbbd2b212+DJAxGdpxcUtc1VTpHLan7dLf055+fvDSNgvzLKPOC0SKLc+ur9fXT50+Ewv/QZ0wpE46NbfjX5rBew89NdVjt4dd7fV2Xu09/fW45Jl7knYend5fBSTQOYgVnpIEDkDAbYXKcXf0Y8JkXx/d6eianZ4gjQvHbs6dhfGtF3lgT2EgSOEgQ4rjkEsNiFGSTMA701jm4wSKXc+YIjIfGHx7KarnaDAnGh/3js0Ua86mioTA9R5i+m8ZG9SIokkdBHYIRIrb7Dp5gs1y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CpXI3DedBP8iJqn7tjjiYojv1sry+Hb5ZF3srhzpsXcIQRvX0PWvTotqty98tMA7TVrG5fQ6xWb3qufI8PK1jmWmdKaQG2Bir+bcCB16vjRpiyuJR11QwOMshn8Q3QRbEftAtySAvCXBDCEsTRdUlSKEAnXqzvtg3SOnG58DT+xwkvpdTDde3z793xVrVFmlUX7kpK40pLF0flLilySyo37wgFXRr1CFi+1IuwWHajqMGRm0WsM9h1to3Mm82Wsy9uJOUh8vIipeHw76QTUddNvvTMLg5yeOQHR3sDvN455WhhqoY0osyFtD13X8nanJvni9mXm4u49RPXux3hxf1XJOnWf1G1J+LS4lxGQgMtwU9nTV/BdFf9ibu0ajivcYp7adcODYnA801MP1rAWH8VZvimFad//dQtB1DDonq7V4wh0T1n/pUJSTz7o7PR3+oPkPV6I78hgKZ76viZ/cxacDTyIzq121XfvTUq96mqRetHo7JufeOIcsCelErj71WhaiuePvTH5ZFZeWbQulQfheMjxdwxHy7lf8sn8p2fDBX8tpKCToLg5K9J7Hz598v5UX/bEbIscmsniRvbrxhf/R1N0bSrQhjLqFYGDi2L50pBzTfj8+T+jFUCEEgLQ2bl3NUszAOrVqpumzKh5AtXEy5O7yZPsfW5aDq1R+KUSiYDO+zZpL+rZXAyEWG6z0zdlSulysouGafjjWOS4XDxVCmzAyd1zGVGoRNGSSX4VXTJYLZh5egG/aPL6Fl+DhF94XfVnovmENc2xk2Fj0KVbzUwv/xpup8BcS0MbZz5lmv5fnr/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, #"Freq_%" = _t, #"Main Seller" = _t, Category = _t, FV = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Freq", Int64.Type}, {"Freq_%", Percentage.Type}}),
Fn_Keep80 =
(myTable as table)=>
[
// _Detail = GroupedRows{[FV="Apples"]}[Fn],
_Detail = myTable,
_SortedRows = Table.Sort(_Detail,{{"Freq_%", Order.Descending}}),
_FreqBuffered = List.Buffer(_SortedRows[Freq]),
_FreqCategory = List.Sum(_FreqBuffered),
_LG = List.Generate(
()=> [x = 0, y = _FreqBuffered{x} ],
each [y] / _FreqCategory < 0.8,
each [x = [x]+1, y = [y] + _FreqBuffered{x} ]
),
_StepBack = _SortedRows,
_KeptFirstRows = Table.FirstN(_StepBack, List.Count(_LG)+1)
][_KeptFirstRows],
GroupedRows = Table.Group(ChangedType, {"FV"}, {{"Fn", Fn_Keep80, type table}}),
CombinedFn = Table.Combine(GroupedRows[Fn])
in
CombinedFn
Hi @Einomi, similar approach as @lbendlin, but with list generate (this one should be faster)
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nVldc6M6Ev0r1DztVs2HJPQBjxgTmwoGFuzJTd29DyRhHdc4dhbbd2b212+DJAxGdpxcUtc1VTpHLan7dLf055+fvDSNgvzLKPOC0SKLc+ur9fXT50+Ewv/QZ0wpE46NbfjX5rBew89NdVjt4dd7fV2Xu09/fW45Jl7knYend5fBSTQOYgVnpIEDkDAbYXKcXf0Y8JkXx/d6eianZ4gjQvHbs6dhfGtF3lgT2EgSOEgQ4rjkEsNiFGSTMA701jm4wSKXc+YIjIfGHx7KarnaDAnGh/3js0Ua86mioTA9R5i+m8ZG9SIokkdBHYIRIrb7Dp5gs1yvds+Wj497iojr2MS1+Tt48tdiU/PMahpHyLOlpDbpTZbvie+Nk9Yt7fooDKi/t4/F01ZiRt5tGE+sNJl788T6RZECC+UViDObInfIkm73xX5bapYYPu2Qjpq25wWjYgOfGh54cf7lBtarINho6KgsNhoQzLMkmevhtjgDKPfVdrtXoGgRwLZmYettRHCjaetDCRtZrfRqMm8WBfeW9HeFdeWJMkowd7i4GOO+Nxp5k8CaFtWThRH8/VjW07vSTQX4hCuoM1yAXzw8FEsTC0Hw17DY0hAkGOO8OaYrOLLySe4cknDCXJAbhw4j5QSe5qG/mOXWF2uSBa3mUGUEBFvzDb2jfH0tq3MkMuaOJwJ+xgVpvncy6WiRXiGjFzmYNN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nA801MP1rAWH8VZvimFad//dQtB1DDonq7V4wh0T1n/pUJSTz7o7PR3+oPkPV6I78hgKZ76viZ/cxacDTyIzq121XfvTUq96mqRetHo7JufeOIcsCelErj71WhaiuePvTH5ZFZeWbQulQfheMjxdwxHy7lf8sn8p2fDBX8tpKCToLg5K9J7Hz598v5UX/bEbIscmsniRvbrxhf/R1N0bSrQhjLqFYGDi2L50pBzTfj8+T+jFUCEEgLQ2bl3NUszAOrVqpumzKh5AtXEy5O7yZPsfW5aDq1R+KUSiYDO+zZpL+rZXAyEWG6z0zdlSulysouGafjjWOS4XDxVCmzAyd1zGVGoRNGSSX4VXTJYLZh5egG/aPL6Fl+DhF94XfVnovmENc2xk2Fj0KVbzUwv/xpup8BcS0MbZz5lmv5fnr/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, #"Freq_%" = _t, #"Main Seller" = _t, Category = _t, FV = _t]),
ChangedType = Table.TransformColumnTypes(Source,{{"Freq", Int64.Type}, {"Freq_%", Percentage.Type}}),
Fn_Keep80 =
(myTable as table)=>
[
// _Detail = GroupedRows{[FV="Apples"]}[Fn],
_Detail = myTable,
_SortedRows = Table.Sort(_Detail,{{"Freq_%", Order.Descending}}),
_FreqBuffered = List.Buffer(_SortedRows[Freq]),
_FreqCategory = List.Sum(_FreqBuffered),
_LG = List.Generate(
()=> [x = 0, y = _FreqBuffered{x} ],
each [y] / _FreqCategory < 0.8,
each [x = [x]+1, y = [y] + _FreqBuffered{x} ]
),
_StepBack = _SortedRows,
_KeptFirstRows = Table.FirstN(_StepBack, List.Count(_LG)+1)
][_KeptFirstRows],
GroupedRows = Table.Group(ChangedType, {"FV"}, {{"Fn", Fn_Keep80, type table}}),
CombinedFn = Table.Combine(GroupedRows[Fn])
in
CombinedFn
@dufoq3 it's an interesting premise and worth exploring further. I came up with another option that goes something like
if only value in list then true
else if running sum <= .8 then true
else if previous running sum < .8 then true
else false
Wonder if this can be reformulated to approach it from a "default of false" perspective.
There is huge difference in speed because your query calculates every single row but my query with list.generate calculates only rows where sum of highest freq is less than 80%. If you use table repeat 10 for your query - processing time on my PC is around 10 seconds (result = 7 613 rows). But if you use repeat 5000 for my query - processing time is around 4 seconds (result = 380 326 rows), but of course at the beginning you have to wait for reapeating table 5000 times which takes some time.
Hi @Einomi ,
It seems that you want to implement Pareto/ABC analysis using PowerQuery M. Try the following steps:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("nVldc6M6Ev0r1DztVs2HJPQBjxgTmwoGFuzJTd29DyRhHdc4dhbbd2b212+DJAxGdpxcUtc1VTpHLan7dLf055+fvDSNgvzLKPOC0SKLc+ur9fXT50+Ewv/QZ0wpE46NbfjX5rBew89NdVjt4dd7fV2Xu09/fW45Jl7knYend5fBSTQOYgVnpIEDkDAbYXKcXf0Y8JkXx/d6eianZ4gjQvHbs6dhfGtF3lgT2EgSOEgQ4rjkEsNiFGSTMA701jm4wSKXc+YIjIfGHx7KarnaDAnGh/3js0Ua86mioTA9R5i+m8ZG9SIokkdBHYIRIrb7Dp5gs1yvds+Wj497iojr2MS1+Tt48tdiU/PMahpHyLOlpDbpTZbvie+Nk9Yt7fooDKi/t4/F01ZiRt5tGE+sNJl788T6RZECC+UViDObInfIkm73xX5bapYYPu2Qjpq25wWjYgOfGh54cf7lBtarINho6KgsNhoQzLMkmevhtjgDKPfVdrtXoGgRwLZmYettRHCjaetDCRtZrfRqMm8WBfeW9HeFdeWJMkowd7i4GOO+Nxp5k8CaFtWThRH8/VjW07vSTQX4hCuoM1yAXzw8FEsTC0Hw17DY0hAkGOO8OaYrOLLySe4cknDCXJAbhw4j5QSe5qG/mOXWF2uSBa3mUGUEBFvzDb2jfH0tq3MkMuaOJwJ+xgVpvncy6WiRXiGjFzmYNN/VXLPwj2Csl6a2l9DmeyfHcWVKFRF25PdOot7ClO9hzOrvepuynkUgIfLsXbk97+PR+iZPTRnE7eZ7F1F3ZYSq3EGZ/K5mug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ufeOIcsCelErj71WhaiuePvTH5ZFZeWbQulQfheMjxdwxHy7lf8sn8p2fDBX8tpKCToLg5K9J7Hz598v5UX/bEbIscmsniRvbrxhf/R1N0bSrQhjLqFYGDi2L50pBzTfj8+T+jFUCEEgLQ2bl3NUszAOrVqpumzKh5AtXEy5O7yZPsfW5aDq1R+KUSiYDO+zZpL+rZXAyEWG6z0zdlSulysouGafjjWOS4XDxVCmzAyd1zGVGoRNGSSX4VXTJYLZh5egG/aPL6Fl+DhF94XfVnovmENc2xk2Fj0KVbzUwv/xpup8BcS0MbZz5lmv5fnr/w==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, #"Freq_%" = _t, #"Main Seller" = _t, Category = _t, FV = _t]),
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Items", type text}, {"Freq", Int64.Type}, {"Freq_%", Int64.Type}, {"Main Seller", type text}, {"Category", type text}, {"FV", type text}}),
#"Grouped Rows" = Table.Group(#"Type modifié", {"FV"}, {{"Data", each Table.AddIndexColumn(Table.Sort(_,{"Freq",Order.Descending}), "Index", 1, 1, Int64.Type)}}),
Custom1 = Table.TransformColumns(#"Grouped Rows",{"Data", (x) => Table.AddColumn(x, "CategoryABC", each if List.Sum(List.FirstN(x[Freq], [Index])) / List.Sum(x[Freq]) <= 0.8 then "A" else "B")}),
Custom2 = Table.TransformColumns(Custom1, {"Data", each Table.SelectRows(_, each [CategoryABC]="A")}),
#"Expanded Data" = Table.ExpandTableColumn(Custom2, "Data", {"Items", "Freq", "Freq_%", "Main Seller", "Category", "CategoryABC"}, {"Items", "Freq", "Freq_%", "Main Seller", "Category", "CategoryABC"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Data", each ([CategoryABC] = "A"))
in
#"Filtered Rows"
ABC classification – DAX Patterns
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
@v-cgao-msft thanks for your suggestion
However, I need all the rows reaching at least 80% of the category, your solution keeps the rows before reaching the 80%
Also, when there is only one item in the category it returns B instead of A
Thanks for your time and for your suggestion
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jZhbk6I4FID/Smqedqu2ZxDx9hgwItXcluD0dM3OA21nlRoEF3Vmen/9JiGJoQXc0uouPZ8nJznX8PXrBxjHPsIPdgKRvUlCDD6Cjx/++GBa9A88Hgty+vDtD4W50Id3iMhfolAwE7ObSWAYPks9k04m9sJH4MOlxMbGO2xjo8T1QiQtno8YcHkh9S4vb6Hl5bzdA5OvZv0fdGywFS3DGmRRuSvy0x44I7WVXhYfs5KxAUPnsw72c+TAZaR8MObH96PaZq9VQ9jw0QtdEEcpTCPwyzIEOmMrx9U5O1dEkiF9ST/M6R87K+lLSBEM8cOKmiUIZr5NslKKUZpEUSqF4xkXk3NdVWeB+BtEd5Z4ygHmbMqo4kLopupc2pHAwEfPoHGrQBdtXzrQtqGLwDqrX8HIoO/vO6ZwwaxyspeXbNdFmgZ9c3LcxyXktdmB0YHE2HM2AQYPwE2QilmLkTE5HkndBzYBct3zMC3d3pykNcAH3he0lGbc5a5W8NwYhltGLAbwpKXZmpt3WJkAzWncgXUrTGvI6mfk+9GTftKToZMWuG7MkBsF3vbMrf4koSnwAGyEZSaYxpTHUV3LPFCUs4ZhikKoCtYNiXyUeNCRqkY8uklB6jzbasiz2saIHf50oTDSTVkifzn0piNyg1zRqE+Roizu8XvUtGO5tef7nlZKnH1eFEoBl/K6f02zyaIXS1QSjCbWDbXPf5CTlBuN+IdSEXnAjh5bllQ5sKvvjdxHAQpTrWvw3TgFOZDyrOqwU1GXlK+klrYyRn7XEBGtfDBcokQivFZTqE1tEhelqVptMuKnW13qHTmf5WobJedF6rK9HF5UEDLhxPg0NcBykzprFTzmEIpC1/ewhOfzbnZqfJpNWmp71p9NPi3a64+6wb8uhm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LqZl4v1kgmmV+JsGggAS+HR9GvBFdOUp5+rsp/5A4Iblwcwns/vsXFSAW3JDRx2AQ6hCm18v8WWX1QCXmQhu/ISW19nf5Dv9SV6JkqJUpJqKV0NAtHW2Mi7dvx2I5iz+uZFEAVOA+aWQGi9vhCOuKq0OmpIb9PP1mQx/qNOHB17oARb6+i/4iff9Qucssxe89qduuU2KHb3j8KdYVi+lPZwY3YGCweXkaDa8nKKGMf0J3PjmCETBZek6PDT0V2Ze5q/st/8A", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Items = _t, Freq = _t, FV = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Freq", Int64.Type}},"fr-FR"),
process = (tbl) =>
let
#"Sorted Rows" = Table.Sort(tbl,{{"Freq", Order.Descending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "First80", each try if List.Sum(List.FirstN(#"Added Index"[Freq],[Index]))/List.Sum(#"Added Index"[Freq])<.8 then true else false otherwise true)
in
#"Added Custom",
#"Grouped Rows" = Table.Group(#"Changed Type", {"FV"}, {{"Rows", each process(_)}}),
#"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Items", "Freq", "First80"}, {"Items", "Freq", "First80"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Rows",{{"Items", type text}, {"Freq", Int64.Type}, {"First80", type logical}})
in
#"Changed Type1"
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.