最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

powerquery - How do I translate a DAX statement into a Power Query M language - Stack Overflow

programmeradmin2浏览0评论

I am recreating a Power BI model into a fabric semantic model, the model has some calculated tables and columns created from existing tables in the model, which fabric does not support. Now I am creating those tables and columns as queries in the dataflow. This means I need to translate the underlying DAX into M in power query. My DAX is quite basic, Could someone please help me to translate the DAX below to M language?

All_Batch = SUMMARIZE('dbo SAMPLE','dbo SAMPLE'[PROJECT_DESC], "BATCH 1", 
MAXX(FILTER('dbo SAMPLE','dbo SAMPLE'[BATCH_ID]="1"),"1"),"BATCH 2", MAXX(FILTER('dbo 
SAMPLE','dbo SAMPLE'[BATCH_ID]="2"),"1"),"BATCH 3", MAXX(FILTER('dbo SAMPLE','dbo 
SAMPLE'[BATCH_ID]="3"),"1"),"BATCH 4", MAXX(FILTER('dbo SAMPLE','dbo 
SAMPLE'[BATCH_ID]="4"),"1"))

I have tried the below:

let
    // Filter for each batch and get a unique value
    Batch1 = Table.SelectRows(dbo_SAMPLE, each [BATCH_ID] = "1"),
    Batch2 = Table.SelectRows(dbo_SAMPLE, each [BATCH_ID] = "2"),
    Batch3 = Table.SelectRows(dbo_SAMPLE, each [BATCH_ID] = "3"),
    Batch4 = Table.SelectRows(dbo_SAMPLE, each [BATCH_ID] = "4"),

    // Summarize by PROJECT_DESC and add batch columns
    GroupedData = Table.Group(dbo_SAMPLE, {"PROJECT_DESC"}, {
        {"BATCH 1", each if Table.IsEmpty(Batch1) then null else "1", type text},
        {"BATCH 2", each if Table.IsEmpty(Batch2) then null else "1", type text},
        {"BATCH 3", each if Table.IsEmpty(Batch3) then null else "1", type text},
        {"BATCH 4", each if Table.IsEmpty(Batch4) then null else "1", type text}
    })
in
    GroupedData

It doesn't give the same result. I know the issue is me not being able to interpret DAX functions properly, I'd appreciate any help

发布评论

评论列表(0)

  1. 暂无评论