Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
PBI_hlpr1
Resolver I
Resolver I

YTD charts with dynamic line selection

Hi all,

 

I have a dataset with two fact tables (actuals and forecast) successfully linked by a calendar table. All works well and the user is able via a slicer to select the period he/she wants for the following chart:

cfugge_5-1674407988225.png

 

Please note that in the visual there is a single measure (Qty) and the Scenario dimension is in the legend of the visual.

 

Here is the slicer:

cfugge_1-1674406593829.png

where the user is allowed to select one or more scenarios.

 

I have then created a measure for YTD figure as follows: 

Qty_YTD = Calculate(sum([Qty]), datesYTD(Dim_Dates[Date],"30/11"))

 

and I need to realise a second chart with YTD values looking as follows:

cfugge_4-1674407784159.png

 

but with the scenario in the legend rather than the FY. The visual seems to work only with the FY in the legend as above. If I replace FY with Scenario it does not work anymore and returns blanks. This clearly because the system cannot filter by year. 

 

Unfortunately the line chart visual does not accept more than one value (e.g. FY and scenario) as legend and just one Y-axis measure when you use a legend.

 

How can I bypass the problem and have a line chart visual with YTD figures compared with the scenarios selected by the user? Is a calculated table the way to go?

 

Many thanks in advance.

 

C.

 

 

The formula have used is simple:

 

Qty_YTD = Calculate(sum(Fact_Actuals[Qty]), datesYTD(Dim_Dates[Date],"30/11"))

 

and works if presented in a matrix visual

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@PBI_hlpr1 Rather hard to debug exactly without sample data. But, you might be running afoul of some weird quirk of the TI function. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@PBI_hlpr1 Rather hard to debug exactly without sample data. But, you might be running afoul of some weird quirk of the TI function. You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler OMG, this seems to work !! I have used the one below:

 

ToHellWithTOTALYTD = 
    VAR __Date = MAX('ProductInventory'[Date])
    VAR __StartOf = DATE(YEAR(__Date),1,1)
    VAR __DATESYTD = FILTER(SELECTCOLUMNS(ALL('ProductInventory'),"Date",[Date]),[Date] >= __StartOf && [Date] <= __Date)
RETURN
    SUMX(FILTER(ALL('ProductInventory'),[Date] IN __DATESYTD),'ProductInventory'[UnitCost]*'ProductInventory'[UnitsBalance])

Unfortunately I do have a FY ending on Nov so I am getting this weird result:

cfugge_0-1674411249223.png

How can I adjust your great formula to consider my FY end?

 

@PBI_hlpr1 Great! For fiscal year stuff, that is generally best handled as part of your date table. It's often best to build everything you need for fiscal year calculations right into the date table itself. Can you give me a sense of your date table? For an example of this, see my 445 custom DAX calendar table. Basically builds everything that is needed right into the date table itself. (1) DAX Custom 445 Calendar - Microsoft Power BI Community.

 

For example, if you had a column that was a fiscal year column such that all rows in the same fiscal year had the same value like FY2022, then it's even easier I think. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler,

 

I do have a date table (linked to the fact tables) and it does have all the fields related to FY management (FY_Period, FY_txt, FY_Qtr, etc.). However looks like your function is using the date measure within the fact table. SHould it still work referring to the date table?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.