Forum Discussion

fabconmvp's avatar
fabconmvp
Helper I
1 year ago
Solved

DAX Help

Hello everyone,


I need help about dax. First of all ı have a table visualization in PBI. And below the image is example of how PBI visualization. I have 2 table. 1 Fact table and other DimDate table. There is a 1(dimdate) to many(fact) based on Date. Weeks and Date comes from DimDate table. Value is a measure which is SUM(Fact[Value]). and I want to create a measure which gives max value for SUM(Fact[Value]) based on weeks and lastly ı have some slicers that needs to effected. So whenever slicer changes max value needs to be effected.

Fact Table:

 

The table I visualized in PBI:

 


Thanks for supports.

  • Hi fabconmvp 

    Please check this

    Max_Weekly_Value_Per_Week =
    VAR CurrentWeek = SELECTEDVALUE('date'[Week])
    VAR WeeklyValues =
        CALCULATETABLE(
            SUMMARIZE(
                Sheet2,
                'date'[Week],
                Sheet2[Value]
            ),
            ALLEXCEPT('date', 'date'[Week])
        )

    RETURN
        MAXX(FILTER(WeeklyValues, 'date'[Week] = CurrentWeek), [Value])

11 Replies

  • Hi fabconmvp 

    Please check this

    Max_Weekly_Value_Per_Week =
    VAR CurrentWeek = SELECTEDVALUE('date'[Week])
    VAR WeeklyValues =
        CALCULATETABLE(
            SUMMARIZE(
                Sheet2,
                'date'[Week],
                Sheet2[Value]
            ),
            ALLEXCEPT('date', 'date'[Week])
        )

    RETURN
        MAXX(FILTER(WeeklyValues, 'date'[Week] = CurrentWeek), [Value])
    • fabconmvp's avatar
      fabconmvp
      Helper I

      Hello,

       

      Firstly, thank you for support. I guess some of the column missing but I modified it in your measure. I'm testing detailly right now that effected other slicers etc. I'm going to accept accept the solution if ı have no question. Thank you for support.
      "

      test =
      VAR CurrentWeek = SELECTEDVALUE(DimDate[WeekNum])
      VAR WeeklyValues =
          CALCULATETABLE(
              SUMMARIZE(
                  'Fact',
                  DimDate[Date],
                  DimDate[WeekNum],
                  "Value",
                  SUM('Fact'[value])
              ),
              ALLEXCEPT(DimDate, DimDate[WeekNum])
          )

      RETURN
          MAXX(FILTER(WeeklyValues, DimDate[WeekNum] = CurrentWeek),[Value])
      "
       
  • Hi,

    Try this measure

    =MAXX(ALLSELECTED(Calendar[weeks]),[Value])

    Hope this helps.

    • fabconmvp's avatar
      fabconmvp
      Helper I

      Hello,

      İt doesn't work. The values doesn't change. Thank you for support.

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        You are welcome.  Share the download link of the PBI file.

  • I think you can use

    Max Value =
    MAXX ( ALLSELECTED ( 'DimDate'[Week] ), [Value] )
    
    • fabconmvp's avatar
      fabconmvp
      Helper I

      Hello,

       

      Thank you for support. However, it didnt work. The values shown as in the first image. 

      • johnt75's avatar
        johnt75
        Super User

        Is your DimDate table marked as a date table ?

  • Hi fabconmvp, Hope you are doing good,

    Please try the below measure:

    Max Value per Week =
    MAXX(
    VALUES(DimDate[Week]),
    CALCULATE( SUM(Fact[Value]) )
    )
    If this post helps to answer your question, please consider accepting it as a solution so others can find it more quickly when they face a similar challenge.


    Proud to be a Microsoft Fabric community super user


    Let's Connect on LinkedIn

    Subscribe to my YouTube channel for Microsoft Fabric and Power BI updates.

    • fabconmvp's avatar
      fabconmvp
      Helper I

      Hello,

       

      Thank you for support. However, it didnt work. The values shown as in the first image.