DAX TOPN 和其他当月动态过滤器

问题描述 投票:0回答:0

这是原始数据。 (https://i.stack.imgur.com/QFGwZ.png) 我正在尝试按当前月份使用 dax 显示 topn 和其他 [text]`,如下图:(https://stackoverflow.com)

谁能帮我解决这个问题? 谢谢你的帮助!

我参考了视频。链接如下: https://www.google.com/search?q=top+n+and+other+&biw=1396&bih=656&sxsrf=APwXEdfpeDckeQu2-I27Tgxo5QLSejIp6w%3A1683041973222&ei=tS5RZO2XDfG02roPg7e6wAE&ved=0ah UKEwitxtL3-9b-AhVxmlYBHYObDhgQ4dUDCBA&uact=5&oq=top+n+and +other+&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIECCMQJzIECCMQJzIECCMQJzIICAAQgAQQywEyCAgAEIAEEMsBMgYIABAFEB4yBggAEAUQHjIGCAAQBRAeMgYIABAFEB4yBggAEAUQHkoECEEYAFD7A1j7A2 DoBmgAcAB4AIABkASIAdoGkgEHMy0xLjAuMZgBAKABAcABAQ&sclient=gws-wiz-serp

它显示了整个月的前N个销售额。 power bi topn and other

Top N Sum Sales = VAR TopProdTable =
TOPN (
    3,
    ALLSELECTED ( 'Product Names'),
    [Sales Amount]
)VAR TopProdSales =
CALCULATE (
   [Sales Amount],
    KEEPFILTERS ( TopProdTable )
)VAR OtherSales =
CALCULATE (                  
    [Sales Amount],
    ALLSELECTED ( 'Product Names' )
)
    - CALCULATE (                        -- subtracting the sales of Top 3 products
       [Sales Amount],
        TopProdTable
    )VAR CurrentProd =
SELECTEDVALUE ( 'Product Names'[group] )RETURN
IF (                                     -- Categorizing as Others and Top Products
    CurrentProd <> "Others",
    TopProdSales,
    OtherSales
)
powerbi dax greatest-n-per-group
© www.soinside.com 2019 - 2024. All rights reserved.