Forum Discussion

ashishd's avatar
ashishd
Icon for Advocate II rankAdvocate II
2 years ago
Solved

Q&A visual setup- how to define an operation like difference from, change from etc.?

Hello friends,   I was wondering if there is any way to define an operation for PowerBI Q&A visual to consider when questions like below are asked? What is the change in sales on the latest date...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ashishd 

     

    Jihwan_Kim Thank you very much for your prompt reply and here allow me to share some of it.

     

    It sounds like you want the Q&A feature to understand and calculate the difference in sales between two dates, specifically the latest date and the previous date.

     

    An effective way to deal with this issue is to create a measure in the Power BI model that is used to calculate the difference in sales between the latest date and the previous date.

     

    Once you have this measure, you can ask the Q&A visual object to display the measure.

     

    Diff = 
    var _maxdate = MAX('Sheet1'[Date])
    var _PreviousDate = CALCULATE(SUM(Sheet1[Metric]), FILTER(ALL('Sheet1'), 'Sheet1'[Date] = _maxdate - 1))
    var _LastDate = CALCULATE(SUM(Sheet1[Metric]), FILTER(ALL('Sheet1'), 'Sheet1'[Date] = _maxdate))
    return _LastDate - _PreviousDate

     

    While you cannot directly define operations like "change" or "difference" in the Q&A setup window, you can use it to define synonyms for measures or columns that might help guide the Q&A feature towards the pre-calculated measure you've created.

     

    You can ask as suggested by Q&A.

     

    Here is the result.

     

     

     

    Use Power BI Q&A to explore and create visuals in your reports - Power BI | Microsoft Learn

     

    Regards,

    Nono Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.