Forum Discussion

SantiagoRandado's avatar
SantiagoRandado
New Member
2 years ago
Solved

Help With DAX Meassure

I have Table Sales with this fields: Value and Date and I have a Table Calendar with Date, Year, Month, Week, Day and Month_Name. I need to create a bar chart showing sales by week, making the last ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, SantiagoRandado 

     

    Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

     

     

    Steps:

    Measures:

    Color =
    
    VAR _lastDay =
    
        CALCULATE ( LASTDATE ( 'Table'[date] ), 'Table'[date] )
    
    VAR _weekDay =
    
        WEEKDAY ( _lastDay )
    
    VAR _firstDayInLastWeek =
    
        CALCULATE ( LASTDATE ( 'Table'[date] ) - _weekDay, ALL ( 'Table' ) )
    
    VAR _lastWeek =
    
        IF ( SELECTEDVALUE ( 'Table'[date] ) >= _firstDayInLastWeek, 1 )
    
    RETURN
    
        IF ( _lastWeek = 1, "light blue", "light Green" )

     

    If this does not work, could you please share some sample data without sensitive information and expected output.
    How to provide sample data in the Power BI Forum - Microsoft Fabric Community

    Best Regards,
    Yang
    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